You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by js...@apache.org on 2026/04/26 20:02:53 UTC
(airflow) branch chart/v1-2x-test updated: [chart/v1-2x-test] Fix database cleanup lifecycle hooks (#65881) (#65898)
This is an automated email from the ASF dual-hosted git repository.
jscheffl pushed a commit to branch chart/v1-2x-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/chart/v1-2x-test by this push:
new d32be2dffc5 [chart/v1-2x-test] Fix database cleanup lifecycle hooks (#65881) (#65898)
d32be2dffc5 is described below
commit d32be2dffc500fea21949466092ece197cc18868
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Sun Apr 26 22:02:47 2026 +0200
[chart/v1-2x-test] Fix database cleanup lifecycle hooks (#65881) (#65898)
(cherry picked from commit 9a9f51bfcd270978cf60eadb41a818640c27fa6c)
Co-authored-by: Henry Chen <he...@gmail.com>
---
.../database-cleanup/database-cleanup-cronjob.yaml | 4 +++
.../airflow_aux/test_database_cleanup.py | 41 ++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/chart/templates/database-cleanup/database-cleanup-cronjob.yaml b/chart/templates/database-cleanup/database-cleanup-cronjob.yaml
index ae506f70800..2c1ab65073a 100644
--- a/chart/templates/database-cleanup/database-cleanup-cronjob.yaml
+++ b/chart/templates/database-cleanup/database-cleanup-cronjob.yaml
@@ -27,6 +27,7 @@
{{- $topologySpreadConstraints := or .Values.databaseCleanup.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowPodSecurityContext" (list .Values.databaseCleanup .Values) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list .Values.databaseCleanup .Values) }}
+{{- $containerLifecycleHooks := or .Values.databaseCleanup.containerLifecycleHooks .Values.containerLifecycleHooks }}
apiVersion: batch/v1
kind: CronJob
metadata:
@@ -95,6 +96,9 @@ spec:
image: {{ template "airflow_image" . }}
imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
securityContext: {{ $containerSecurityContext | nindent 16 }}
+ {{- if $containerLifecycleHooks }}
+ lifecycle: {{- tpl (toYaml $containerLifecycleHooks) . | nindent 16 }}
+ {{- end }}
{{- if .Values.databaseCleanup.command }}
command: {{ tpl (toYaml .Values.databaseCleanup.command) . | nindent 16 }}
{{- end }}
diff --git a/helm-tests/tests/helm_tests/airflow_aux/test_database_cleanup.py b/helm-tests/tests/helm_tests/airflow_aux/test_database_cleanup.py
index 9c4db3a0dab..c7d90c785a0 100644
--- a/helm-tests/tests/helm_tests/airflow_aux/test_database_cleanup.py
+++ b/helm-tests/tests/helm_tests/airflow_aux/test_database_cleanup.py
@@ -419,6 +419,47 @@ class TestDatabaseCleanup:
== resources
)
+ @pytest.mark.parametrize(
+ "values",
+ [
+ pytest.param(
+ {
+ "databaseCleanup": {
+ "enabled": True,
+ "containerLifecycleHooks": {"preStop": {"exec": {"command": ["echo", "cleanup"]}}},
+ },
+ },
+ id="component",
+ ),
+ pytest.param(
+ {
+ "databaseCleanup": {"enabled": True},
+ "containerLifecycleHooks": {"preStop": {"exec": {"command": ["echo", "cleanup"]}}},
+ },
+ id="global-fallback",
+ ),
+ pytest.param(
+ {
+ "databaseCleanup": {
+ "enabled": True,
+ "containerLifecycleHooks": {"preStop": {"exec": {"command": ["echo", "cleanup"]}}},
+ },
+ "containerLifecycleHooks": {"postStart": {"exec": {"command": ["echo", "global"]}}},
+ },
+ id="component-overrides-global",
+ ),
+ ],
+ )
+ def test_should_render_container_lifecycle_hooks(self, values):
+ docs = render_chart(
+ values=values,
+ show_only=["templates/database-cleanup/database-cleanup-cronjob.yaml"],
+ )
+
+ assert jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].lifecycle", docs[0]) == {
+ "preStop": {"exec": {"command": ["echo", "cleanup"]}}
+ }
+
def test_should_set_job_history_limits(self):
docs = render_chart(
values={