Skip to content

Commit

Permalink
fix(helm): set worker safeToEvict properly (#35130)
Browse files Browse the repository at this point in the history
* fix(helm): set worker safeToEvict properly
  • Loading branch information
hakuno committed Oct 27, 2023
1 parent 04e2fbd commit 764a0e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 1 addition & 3 deletions chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ spec:
checksum/airflow-config: {{ include (print $.Template.BasePath "/configmaps/configmap.yaml") . | sha256sum }}
checksum/extra-configmaps: {{ include (print $.Template.BasePath "/configmaps/extra-configmaps.yaml") . | sha256sum }}
checksum/extra-secrets: {{ include (print $.Template.BasePath "/secrets/extra-secrets.yaml") . | sha256sum }}
{{- if .Values.workers.safeToEvict }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- end }}
cluster-autoscaler.kubernetes.io/safe-to-evict: {{ .Values.workers.safeToEvict | quote }}
{{- if .Values.airflowPodAnnotations }}
{{- toYaml .Values.airflowPodAnnotations | nindent 8 }}
{{- end }}
Expand Down
16 changes: 16 additions & 0 deletions helm_tests/airflow_core/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,22 @@ def test_should_add_component_specific_annotations(self):
assert "annotations" in jmespath.search("metadata", docs[0])
assert jmespath.search("metadata.annotations", docs[0])["test_annotation"] == "test_annotation_value"

@pytest.mark.parametrize(
"evictionStr, evictionBool",
[("true", True), ("false", False)],
)
def test_safetoevict_annotations(self, evictionStr, evictionBool):
docs = render_chart(
values={"workers": {"safeToEvict": evictionBool}},
show_only=["templates/workers/worker-deployment.yaml"],
)
assert (
jmespath.search("spec.template.metadata.annotations", docs[0])[
"cluster-autoscaler.kubernetes.io/safe-to-evict"
]
== evictionStr
)


class TestWorkerLogGroomer(LogGroomerTestBase):
"""Worker groomer."""
Expand Down

0 comments on commit 764a0e3

Please sign in to comment.