Skip to content

Commit

Permalink
fix: duplicated keys in annotations caused by airfowPodAnnotations va…
Browse files Browse the repository at this point in the history
…lue being overwritten by safeToEvict value of worker (apache#40554)
  • Loading branch information
rzjfr authored Jul 9, 2024
1 parent 270aa11 commit 5323471
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions helm_tests/airflow_aux/test_pod_template_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,27 @@ def test_safe_to_evict_annotation(self, safe_to_evict: bool):
"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!"}}},
Expand Down

0 comments on commit 5323471

Please sign in to comment.