This is an automated email from the ASF dual-hosted git repository.
rom 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 20a481cc03 fix(helm): render global volumes and volume mounts into
cleanup job (#40191) (#42268)
20a481cc03 is described below
commit 20a481cc0338267983527ea95b0a8be0484639e5
Author: Daniel Gellert <[email protected]>
AuthorDate: Tue Sep 17 09:56:35 2024 +0200
fix(helm): render global volumes and volume mounts into cleanup job
(#40191) (#42268)
* fix(helm): render global volumes and volume mounts in cleanup job (#64056)
* fix(helm): allow to deactivate cleanup job history (#64056)
---
chart/templates/cleanup/cleanup-cronjob.yaml | 13 ++++++++---
helm_tests/airflow_aux/test_cleanup_pods.py | 34 ++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/chart/templates/cleanup/cleanup-cronjob.yaml
b/chart/templates/cleanup/cleanup-cronjob.yaml
index 5afab9462b..1e8da267e5 100644
--- a/chart/templates/cleanup/cleanup-cronjob.yaml
+++ b/chart/templates/cleanup/cleanup-cronjob.yaml
@@ -47,10 +47,10 @@ spec:
schedule: "{{ tpl .Values.cleanup.schedule . }}"
# The cron job does not allow concurrent runs; if it is time for a new job
run and the previous job run hasn't finished yet, the cron job skips the new
job run
concurrencyPolicy: Forbid
- {{- if .Values.cleanup.failedJobsHistoryLimit }}
+ {{- if not ( eq .Values.cleanup.failedJobsHistoryLimit nil) }}
failedJobsHistoryLimit: {{ .Values.cleanup.failedJobsHistoryLimit }}
{{- end }}
- {{- if .Values.cleanup.successfulJobsHistoryLimit }}
+ {{- if not (eq .Values.cleanup.successfulJobsHistoryLimit nil) }}
successfulJobsHistoryLimit: {{ .Values.cleanup.successfulJobsHistoryLimit }}
{{- end }}
jobTemplate:
@@ -105,10 +105,17 @@ spec:
env:
{{- include "standard_airflow_environment" . | indent 12 }}
{{- include "container_extra_envs" (list .
.Values.cleanup.env) | indent 12 }}
- volumeMounts: {{- include "airflow_config_mount" . | nindent 16
}}
+ volumeMounts:
+ {{- include "airflow_config_mount" . | nindent 16 }}
+ {{- if .Values.volumeMounts }}
+ {{- toYaml .Values.volumeMounts | nindent 16 }}
+ {{- end }}
resources: {{- toYaml .Values.cleanup.resources | nindent 16 }}
volumes:
- name: config
configMap:
name: {{ template "airflow_config" . }}
+ {{- if .Values.volumes }}
+ {{- toYaml .Values.volumes | nindent 12 }}
+ {{- end }}
{{- end }}
diff --git a/helm_tests/airflow_aux/test_cleanup_pods.py
b/helm_tests/airflow_aux/test_cleanup_pods.py
index 4305531ec5..d63132f50b 100644
--- a/helm_tests/airflow_aux/test_cleanup_pods.py
+++ b/helm_tests/airflow_aux/test_cleanup_pods.py
@@ -96,6 +96,8 @@ class TestCleanupPods:
"subPath": "airflow.cfg",
"readOnly": True,
} in
jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].volumeMounts",
docs[0])
+ assert "successfulJobsHistoryLimit" not in docs[0]["spec"]
+ assert "failedJobsHistoryLimit" not in docs[0]["spec"]
def test_should_pass_validation_with_v1beta1_api(self):
render_chart(
@@ -327,6 +329,20 @@ class TestCleanupPods:
assert 2 == jmespath.search("spec.failedJobsHistoryLimit", docs[0])
assert 4 == jmespath.search("spec.successfulJobsHistoryLimit", docs[0])
+ def test_should_set_zero_job_history_limits(self):
+ docs = render_chart(
+ values={
+ "cleanup": {
+ "enabled": True,
+ "failedJobsHistoryLimit": 0,
+ "successfulJobsHistoryLimit": 0,
+ },
+ },
+ show_only=["templates/cleanup/cleanup-cronjob.yaml"],
+ )
+ assert 0 == jmespath.search("spec.failedJobsHistoryLimit", docs[0])
+ assert 0 == jmespath.search("spec.successfulJobsHistoryLimit", docs[0])
+
def test_no_airflow_local_settings(self):
docs = render_chart(
values={
@@ -355,6 +371,24 @@ class TestCleanupPods:
"readOnly": True,
} in
jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].volumeMounts",
docs[0])
+ def test_global_volumes_and_volume_mounts(self):
+ docs = render_chart(
+ values={
+ "cleanup": {"enabled": True},
+ "volumes": [{"name": "test-volume", "emptyDir": {}}],
+ "volumeMounts": [{"name": "test-volume", "mountPath":
"/test"}],
+ },
+ show_only=["templates/cleanup/cleanup-cronjob.yaml"],
+ )
+ assert {
+ "name": "test-volume",
+ "mountPath": "/test",
+ } in
jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].volumeMounts",
docs[0])
+ assert {
+ "name": "test-volume",
+ "emptyDir": {},
+ } in jmespath.search("spec.jobTemplate.spec.template.spec.volumes",
docs[0])
+
class TestCleanupServiceAccount:
"""Tests cleanup of service accounts."""