You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by di...@apache.org on 2020/08/07 17:00:21 UTC

[airflow] branch v1-10-test updated: init-container fix

This is an automated email from the ASF dual-hosted git repository.

dimberman pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v1-10-test by this push:
     new 3773dac  init-container fix
3773dac is described below

commit 3773dac25a9b8a83bd7ef5e52938a3a92ceede75
Author: Daniel Imberman <da...@gmail.com>
AuthorDate: Fri Aug 7 09:58:59 2020 -0700

    init-container fix
---
 airflow/kubernetes/secret.py          |  2 +-
 tests/kubernetes/test_pod_launcher.py | 21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/airflow/kubernetes/secret.py b/airflow/kubernetes/secret.py
index eeacdad..df07747 100644
--- a/airflow/kubernetes/secret.py
+++ b/airflow/kubernetes/secret.py
@@ -55,7 +55,7 @@ class Secret(K8SModel):
             # if deploying to env, capitalize the deploy target
             self.deploy_target = deploy_target.upper()
 
-        if key is not None and deploy_target is None:
+        if key is not None and deploy_target is None and deploy_type == "env":
             raise AirflowConfigException(
                 'If `key` is set, `deploy_target` should not be None'
             )
diff --git a/tests/kubernetes/test_pod_launcher.py b/tests/kubernetes/test_pod_launcher.py
index c86a6cf..de7e147 100644
--- a/tests/kubernetes/test_pod_launcher.py
+++ b/tests/kubernetes/test_pod_launcher.py
@@ -178,6 +178,12 @@ class TestPodLauncherHelper(unittest.TestCase):
                 namespace="bar"
             ),
             spec=k8s.V1PodSpec(
+                init_containers=[
+                    k8s.V1Container(
+                        name="init-container",
+                        volume_mounts=[k8s.V1VolumeMount(mount_path="/tmp", name="init-secret")]
+                    )
+                ],
                 containers=[
                     k8s.V1Container(
                         name="base",
@@ -238,6 +244,12 @@ class TestPodLauncherHelper(unittest.TestCase):
                             secret_name="secret-name",
 
                         )
+                    ),
+                    k8s.V1Volume(
+                        name="init-secret",
+                        secret=k8s.V1SecretVolumeSource(
+                            secret_name="secret-name",
+                        )
                     )
                 ]
             )
@@ -248,6 +260,12 @@ class TestPodLauncherHelper(unittest.TestCase):
             name="foo",
             namespace="bar",
             envs={},
+            init_containers=[
+                k8s.V1Container(
+                    name="init-container",
+                    volume_mounts=[k8s.V1VolumeMount(mount_path="/tmp", name="init-secret")]
+                )
+            ],
             cmds=["foo"],
             image="myimage",
             ports=[
@@ -273,7 +291,8 @@ class TestPodLauncherHelper(unittest.TestCase):
                     sub_path=None,
                 )],
             secrets=[Secret("env", "AIRFLOW_SECRET", "ai", "secret_key"),
-                     Secret('volume', '/opt/mount', 'airflow-secret', "secret-name")],
+                     Secret('volume', '/opt/mount', 'airflow-secret', "secret-name"),
+                     Secret('volume', None, 'init-secret', 'secret-name')],
             security_context={'fsGroup': 0, 'runAsUser': 0},
             volumes=[Volume(name="myvolume", configs={'name': 'myvolume'}),
                      Volume(name="airflow-config", configs={'configMap': {'data': 'airflow-data'},