This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch v1-10-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit fda5f7ad5f366aa8469f944b02a60c0a00ab8a8a Author: Daniel Imberman <[email protected]> AuthorDate: Wed Nov 11 09:23:20 2020 -0800 Fix indentation for affinities in helm chart (#12288) This PR fixes a bug in the helm chart where custom affinities in the pod_template_file cause the yaml to fail due to invalid spacing (cherry picked from commit cbe4ef2c5e143c87c9edd1c54a4949bbdd7a8edd) --- chart/files/pod-template-file.kubernetes-helm-yaml | 9 ++-- chart/tests/test_pod_template_file.py | 51 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml index 8647060..b4ec9a5 100644 --- a/chart/files/pod-template-file.kubernetes-helm-yaml +++ b/chart/files/pod-template-file.kubernetes-helm-yaml @@ -66,12 +66,9 @@ spec: restartPolicy: Never securityContext: runAsUser: {{ .Values.uid }} - nodeSelector: - {{ toYaml .Values.nodeSelector | indent 8 }} - affinity: - {{ toYaml .Values.affinity | indent 8 }} - tolerations: - {{ toYaml .Values.tolerations | indent 8 }} + nodeSelector: {{ toYaml .Values.nodeSelector | nindent 4 }} + affinity: {{ toYaml .Values.affinity | nindent 4 }} + tolerations: {{ toYaml .Values.tolerations | nindent 4 }} serviceAccountName: '{{ .Release.Name }}-worker' volumes: {{- if .Values.dags.persistence.enabled }} diff --git a/chart/tests/test_pod_template_file.py b/chart/tests/test_pod_template_file.py index d9334de..3c61733 100644 --- a/chart/tests/test_pod_template_file.py +++ b/chart/tests/test_pod_template_file.py @@ -184,3 +184,54 @@ class PodTemplateFileTest(unittest.TestCase): self.assertRegex(docs[0]["kind"], "Pod") self.assertEqual("dummy_image:latest", jmespath.search("spec.containers[0].image", docs[0])) self.assertEqual("base", jmespath.search("spec.containers[0].name", docs[0])) + + def test_should_create_valid_affinity_and_node_selector(self): + docs = render_chart( + values={ + "affinity": { + "nodeAffinity": { + "requiredDuringSchedulingIgnoredDuringExecution": { + "nodeSelectorTerms": [ + { + "matchExpressions": [ + {"key": "foo", "operator": "In", "values": ["true"]}, + ] + } + ] + } + } + }, + "tolerations": [ + {"key": "dynamic-pods", "operator": "Equal", "value": "true", "effect": "NoSchedule"} + ], + "nodeSelector": {"diskType": "ssd"}, + }, + show_only=["templates/pod-template-file.yaml"], + ) + + self.assertRegex(docs[0]["kind"], "Pod") + self.assertEqual( + "foo", + jmespath.search( + "spec.affinity.nodeAffinity." + "requiredDuringSchedulingIgnoredDuringExecution." + "nodeSelectorTerms[0]." + "matchExpressions[0]." + "key", + docs[0], + ), + ) + self.assertEqual( + "ssd", + jmespath.search( + "spec.nodeSelector.diskType", + docs[0], + ), + ) + self.assertEqual( + "dynamic-pods", + jmespath.search( + "spec.tolerations[0].key", + docs[0], + ), + )
