This is an automated email from the ASF dual-hosted git repository.
Miretpl 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 098496fd3b4 [chart/v1-2x-test] Allow mounting the Airflow config as a
directory to avoid the subPath mount race (#70180) (#77194)
098496fd3b4 is described below
commit 098496fd3b443970541a20b79b9f6104527e0d2e
Author: Diego Álvarez <[email protected]>
AuthorDate: Thu Nov 19 23:18:10 2026 +0100
[chart/v1-2x-test] Allow mounting the Airflow config as a directory to
avoid the subPath mount race (#70180) (#77194)
Manual backport of #70180. The automatic backport failed on a conflict in
test_airflow_common.py, where chart/v1-2x-test parametrizes
test_priority_class_name; both sides are kept.
test_config_mounted_via_subpath_by_default is adapted to the 1.x default:
this branch ships a non-empty airflowLocalSettings, so
airflow_local_settings.py is mounted via subPath by default.
(cherry picked from commit 9e6126a19c1bb15958219156f205be6cf01867f4)
Co-authored-by: diego15ag <[email protected]>
---
chart/templates/_helpers.yaml | 14 ++++
chart/values.schema.json | 6 ++
chart/values.yaml | 4 +
.../helm_tests/airflow_aux/test_airflow_common.py | 87 ++++++++++++++++++++++
4 files changed, 111 insertions(+)
diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml
index 807f2f926e9..860b7ad293a 100644
--- a/chart/templates/_helpers.yaml
+++ b/chart/templates/_helpers.yaml
@@ -63,6 +63,10 @@ If release name contains chart name it will be used as a
full name.
# Hard Coded Airflow Envs
- name: AIRFLOW_HOME
value: {{ .Values.airflowHome }}
+ {{- if .Values.mountConfigAsDir }}
+ - name: AIRFLOW_CONFIG
+ value: {{ printf "%s/airflow.cfg" (include "airflow_config_dir" .) | quote
}}
+ {{- end }}
{{- if .Values.enableBuiltInSecretEnvVars.AIRFLOW__CORE__FERNET_KEY }}
- name: AIRFLOW__CORE__FERNET_KEY
valueFrom:
@@ -717,7 +721,16 @@ server_tls_key_file = /etc/pgbouncer/server.key
{{- printf "%s-config" (include "airflow.fullname" .) }}
{{- end }}
+{{- define "airflow_config_dir" -}}
+ {{- printf "%s/config" .Values.airflowHome }}
+{{- end }}
+
{{- define "airflow_config_mount" -}}
+{{- if .Values.mountConfigAsDir }}
+- name: config
+ mountPath: {{ include "airflow_config_dir" . | quote }}
+ readOnly: true
+{{- else }}
- name: config
mountPath: {{ template "airflow_config_path" . }}
subPath: airflow.cfg
@@ -729,6 +742,7 @@ server_tls_key_file = /etc/pgbouncer/server.key
readOnly: true
{{- end }}
{{- end }}
+{{- end }}
{{/* Helper for service account name generation */}}
{{- define "_serviceAccountNameGen" -}}
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 8a192e48625..e4a8420ef64 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -810,6 +810,12 @@
"x-docsSection": "Common",
"default": "See values.yaml"
},
+ "mountConfigAsDir": {
+ "description": "Mount the Airflow config ConfigMap as a directory
(at ``{airflowHome}/config``) and set accordingly, instead of mounting
``airflow.cfg`` via ``subPath``.",
+ "type": "boolean",
+ "x-docsSection": "Kubernetes",
+ "default": false
+ },
"rbac": {
"description": "Enable RBAC (default on most clusters these
days).",
"type": "object",
diff --git a/chart/values.yaml b/chart/values.yaml
index 31486fa8be1..8b52143243a 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -375,6 +375,10 @@ airflowLocalSettings: |-
{{- end }}
{{- end }}
+# Mount the Airflow config ConfigMap as a directory (at
``{airflowHome}/config``) and set
+# accordingly, instead of mounting ``airflow.cfg`` via ``subPath``.
+mountConfigAsDir: false
+
# Enable RBAC (default on most clusters these days)
rbac:
# Specifies whether RBAC resources should be created
diff --git a/helm-tests/tests/helm_tests/airflow_aux/test_airflow_common.py
b/helm-tests/tests/helm_tests/airflow_aux/test_airflow_common.py
index 958c9cf3b02..37d2ed067df 100644
--- a/helm-tests/tests/helm_tests/airflow_aux/test_airflow_common.py
+++ b/helm-tests/tests/helm_tests/airflow_aux/test_airflow_common.py
@@ -551,6 +551,93 @@ class TestAirflowCommon:
for doc in docs:
assert expected_mount in
jmespath.search("spec.template.spec.initContainers[0].volumeMounts", doc)
+ def test_mount_config_as_dir(self):
+ components = [
+ "templates/scheduler/scheduler-deployment.yaml",
+ "templates/workers/worker-deployment.yaml",
+ "templates/api-server/api-server-deployment.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/dag-processor/dag-processor-deployment.yaml",
+ "templates/flower/flower-deployment.yaml",
+ "templates/cleanup/cleanup-cronjob.yaml",
+ "templates/database-cleanup/database-cleanup-cronjob.yaml",
+ "templates/jobs/migrate-database-job.yaml",
+ "templates/jobs/create-user-job.yaml",
+ ]
+ docs = render_chart(
+ values={
+ "mountConfigAsDir": True,
+ "airflowLocalSettings": "# local settings",
+ "executor": "CeleryExecutor,KubernetesExecutor",
+ "flower": {"enabled": True},
+ "cleanup": {"enabled": True},
+ "databaseCleanup": {"enabled": True},
+ },
+ show_only=components,
+ )
+ dir_mount = {"name": "config", "mountPath": "/opt/airflow/config",
"readOnly": True}
+ for doc in docs:
+ pod = "spec.jobTemplate.spec.template.spec" if doc["kind"] ==
"CronJob" else "spec.template.spec"
+ assert
jmespath.search(f"{pod}.containers[0].volumeMounts[?name=='config' &&
!subPath]", doc) == [
+ dir_mount
+ ]
+ assert (
+ jmespath.search(
+ f"{pod}.containers[0].volumeMounts[?subPath=='airflow.cfg'
|| subPath=='airflow_local_settings.py']",
+ doc,
+ )
+ == []
+ )
+ assert
jmespath.search(f"{pod}.containers[0].env[?name=='AIRFLOW_CONFIG'].value", doc)
== [
+ "/opt/airflow/config/airflow.cfg"
+ ]
+
+ def test_config_mounted_via_subpath_by_default(self):
+ docs =
render_chart(show_only=["templates/scheduler/scheduler-deployment.yaml"])
+ mounts = "spec.template.spec.containers[0].volumeMounts"
+ assert jmespath.search(f"{mounts}[?subPath=='airflow.cfg']", docs[0])
== [
+ {
+ "name": "config",
+ "mountPath": "/opt/airflow/airflow.cfg",
+ "subPath": "airflow.cfg",
+ "readOnly": True,
+ }
+ ]
+ # The 1.x chart ships a default airflowLocalSettings, so it is mounted
too.
+ assert
jmespath.search(f"{mounts}[?subPath=='airflow_local_settings.py']", docs[0]) ==
[
+ {
+ "name": "config",
+ "mountPath": "/opt/airflow/config/airflow_local_settings.py",
+ "subPath": "airflow_local_settings.py",
+ "readOnly": True,
+ }
+ ]
+ assert jmespath.search(f"{mounts}[?name=='config' && !subPath]",
docs[0]) == []
+ assert
jmespath.search("spec.template.spec.containers[0].env[?name=='AIRFLOW_CONFIG']",
docs[0]) == []
+
+ def test_local_settings_mounted_via_subpath_when_set(self):
+ docs = render_chart(
+ values={"airflowLocalSettings": "# local settings"},
+ show_only=["templates/scheduler/scheduler-deployment.yaml"],
+ )
+ mounts = "spec.template.spec.containers[0].volumeMounts"
+ assert jmespath.search(f"{mounts}[?subPath=='airflow.cfg']", docs[0])
== [
+ {
+ "name": "config",
+ "mountPath": "/opt/airflow/airflow.cfg",
+ "subPath": "airflow.cfg",
+ "readOnly": True,
+ }
+ ]
+ assert
jmespath.search(f"{mounts}[?subPath=='airflow_local_settings.py']", docs[0]) ==
[
+ {
+ "name": "config",
+ "mountPath": "/opt/airflow/config/airflow_local_settings.py",
+ "subPath": "airflow_local_settings.py",
+ "readOnly": True,
+ }
+ ]
+
@pytest.mark.parametrize(
"workers_values",
[