You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/01/07 22:32:49 UTC

[airflow] branch master updated: Fix known-hosts volume name (#13457)

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

kaxilnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 3998711  Fix known-hosts volume name (#13457)
3998711 is described below

commit 39987118f63804e90016a874ef17066d32e9f6c0
Author: Jun <Ju...@users.noreply.github.com>
AuthorDate: Fri Jan 8 06:32:36 2021 +0800

    Fix known-hosts volume name (#13457)
---
 chart/files/pod-template-file.kubernetes-helm-yaml |  4 +--
 chart/tests/test_pod_template_file.py              | 35 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml
index 33ae7b5..a1a7730 100644
--- a/chart/files/pod-template-file.kubernetes-helm-yaml
+++ b/chart/files/pod-template-file.kubernetes-helm-yaml
@@ -22,7 +22,7 @@ metadata:
 spec:
 {{- if .Values.dags.gitSync.enabled }}
   initContainers:
-{{- include "git_sync_container" (dict "Values" .Values "is_init" "true") | indent 8 }}
+{{- include "git_sync_container" (dict "Values" .Values "is_init" "true") | indent 4 }}
 {{- end }}
   containers:
     - args: []
@@ -53,7 +53,7 @@ spec:
 {{- end }}
 {{- if .Values.dags.gitSync.knownHosts }}
         - mountPath: /etc/git-secret/known_hosts
-          name: {{ .Values.dags.gitSync.knownHosts }}
+          name: git-sync-known-hosts
           subPath: known_hosts
 {{- end }}
 {{- if .Values.dags.gitSync.sshKeySecret }}
diff --git a/chart/tests/test_pod_template_file.py b/chart/tests/test_pod_template_file.py
index 768638f..bd0b7ac 100644
--- a/chart/tests/test_pod_template_file.py
+++ b/chart/tests/test_pod_template_file.py
@@ -135,6 +135,41 @@ class PodTemplateFileTest(unittest.TestCase):
             jmespath.search("spec.volumes", docs[0]),
         )
 
+    def test_validate_if_ssh_known_hosts_are_added(self):
+        docs = render_chart(
+            values={
+                "dags": {
+                    "gitSync": {
+                        "enabled": True,
+                        "containerName": "git-sync-test",
+                        "sshKeySecret": "ssh-secret",
+                        "knownHosts": "github.com ssh-rsa AAAABdummy",
+                        "branch": "test-branch",
+                    }
+                }
+            },
+            show_only=["templates/pod-template-file.yaml"],
+        )
+        self.assertIn(
+            {"name": "GIT_KNOWN_HOSTS", "value": "true"},
+            jmespath.search("spec.initContainers[0].env", docs[0]),
+        )
+        self.assertIn(
+            {
+                "name": "git-sync-known-hosts",
+                "configMap": {"defaultMode": 288, "name": "RELEASE-NAME-airflow-config"},
+            },
+            jmespath.search("spec.volumes", docs[0]),
+        )
+        self.assertIn(
+            {
+                "name": "git-sync-known-hosts",
+                "mountPath": "/etc/git-secret/known_hosts",
+                "subPath": "known_hosts",
+            },
+            jmespath.search("spec.containers[0].volumeMounts", docs[0]),
+        )
+
     def test_should_set_username_and_pass_env_variables(self):
         docs = render_chart(
             values={