This is an automated email from the ASF dual-hosted git repository. jedcunningham pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push: new 5323471166 fix: duplicated keys in annotations caused by airfowPodAnnotations value being overwritten by safeToEvict value of worker (#40554) 5323471166 is described below commit 5323471166ec9b2dfaf7ec0940a5a55b50d49e73 Author: Reza J. Bavaghoush <rz...@users.noreply.github.com> AuthorDate: Tue Jul 9 18:19:24 2024 +0200 fix: duplicated keys in annotations caused by airfowPodAnnotations value being overwritten by safeToEvict value of worker (#40554) --- chart/files/pod-template-file.kubernetes-helm-yaml | 2 +- helm_tests/airflow_aux/test_pod_template_file.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml index 4219225616..259f6a71b8 100644 --- a/chart/files/pod-template-file.kubernetes-helm-yaml +++ b/chart/files/pod-template-file.kubernetes-helm-yaml @@ -27,7 +27,7 @@ {{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.workers) }} {{- $containerLifecycleHooks := or .Values.workers.containerLifecycleHooks .Values.containerLifecycleHooks }} {{- $safeToEvict := dict "cluster-autoscaler.kubernetes.io/safe-to-evict" (.Values.workers.safeToEvict | toString) }} -{{- $podAnnotations := mergeOverwrite .Values.airflowPodAnnotations $safeToEvict .Values.workers.podAnnotations }} +{{- $podAnnotations := mergeOverwrite (deepCopy .Values.airflowPodAnnotations) $safeToEvict .Values.workers.podAnnotations }} apiVersion: v1 kind: Pod metadata: diff --git a/helm_tests/airflow_aux/test_pod_template_file.py b/helm_tests/airflow_aux/test_pod_template_file.py index 1efccbf410..43a8d19423 100644 --- a/helm_tests/airflow_aux/test_pod_template_file.py +++ b/helm_tests/airflow_aux/test_pod_template_file.py @@ -660,6 +660,27 @@ class TestPodTemplateFile: "cluster-autoscaler.kubernetes.io/safe-to-evict": "true" if safe_to_evict else "false" } + def test_safe_to_evict_annotation_other_services(self): + """Workers' safeToEvict value should not overwrite safeToEvict value of other services.""" + docs = render_chart( + values={ + "workers": {"safeToEvict": False}, + "scheduler": {"safeToEvict": True}, + "triggerer": {"safeToEvict": True}, + "executor": "KubernetesExecutor", + "dagProcessor": {"enabled": True, "safeToEvict": True}, + }, + show_only=[ + "templates/dag-processor/dag-processor-deployment.yaml", + "templates/triggerer/triggerer-deployment.yaml", + "templates/scheduler/scheduler-deployment.yaml", + ], + chart_dir=self.temp_chart_dir, + ) + for doc in docs: + annotations = jmespath.search("spec.template.metadata.annotations", doc) + assert annotations.get("cluster-autoscaler.kubernetes.io/safe-to-evict") == "true" + def test_workers_pod_annotations(self): docs = render_chart( values={"workers": {"podAnnotations": {"my_annotation": "annotated!"}}},