This is an automated email from the ASF dual-hosted git repository.

jscheffl 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 3935c86a69d fix: scheduler, triggerer, worker airflow components have 
inconsistent log volume (#56418)
3935c86a69d is described below

commit 3935c86a69d5e8a92bac88716cad74535174a32c
Author: KUAN-HAO HUANG <[email protected]>
AuthorDate: Mon Dec 8 06:31:23 2025 +0800

    fix: scheduler, triggerer, worker airflow components have inconsistent log 
volume (#56418)
    
    * fix logs mount
    
    * helm test
    
    * fix error
    
    * try to fix error
---
 .../templates/scheduler/scheduler-deployment.yaml  |  5 ++++
 .../templates/triggerer/triggerer-deployment.yaml  |  5 ++++
 chart/templates/workers/worker-deployment.yaml     |  5 ++++
 .../helm_tests/airflow_core/test_scheduler.py      | 31 +++++++++++++++++++++
 .../helm_tests/airflow_core/test_triggerer.py      | 32 ++++++++++++++++++++++
 .../tests/helm_tests/airflow_core/test_worker.py   | 32 ++++++++++++++++++++++
 6 files changed, 110 insertions(+)

diff --git a/chart/templates/scheduler/scheduler-deployment.yaml 
b/chart/templates/scheduler/scheduler-deployment.yaml
index 53e2975cc40..2e93213094e 100644
--- a/chart/templates/scheduler/scheduler-deployment.yaml
+++ b/chart/templates/scheduler/scheduler-deployment.yaml
@@ -150,6 +150,11 @@ spec:
           imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
           securityContext: {{ $containerSecurityContextWaitForMigrations | 
nindent 12 }}
           volumeMounts:
+            - name: logs
+              mountPath: "/opt/airflow/logs"
+              {{- if .Values.logs.persistence.subPath }}
+              subPath: {{ .Values.logs.persistence.subPath }}
+              {{- end }}
             {{- include "airflow_config_mount" . | nindent 12 }}
             {{- if .Values.volumeMounts }}
               {{- toYaml .Values.volumeMounts | nindent 12 }}
diff --git a/chart/templates/triggerer/triggerer-deployment.yaml 
b/chart/templates/triggerer/triggerer-deployment.yaml
index 21cddea9521..6b140eeffa3 100644
--- a/chart/templates/triggerer/triggerer-deployment.yaml
+++ b/chart/templates/triggerer/triggerer-deployment.yaml
@@ -140,6 +140,11 @@ spec:
           imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
           securityContext: {{ $containerSecurityContextWaitForMigrations | 
nindent 12 }}
           volumeMounts:
+            - name: logs
+              mountPath: "/opt/airflow/logs"
+              {{- if .Values.logs.persistence.subPath }}
+              subPath: {{ .Values.logs.persistence.subPath }}
+              {{- end }}
             {{- include "airflow_config_mount" . | nindent 12 }}
             {{- if .Values.volumeMounts }}
               {{- toYaml .Values.volumeMounts | nindent 12 }}
diff --git a/chart/templates/workers/worker-deployment.yaml 
b/chart/templates/workers/worker-deployment.yaml
index ee7277d265e..e41fa35add2 100644
--- a/chart/templates/workers/worker-deployment.yaml
+++ b/chart/templates/workers/worker-deployment.yaml
@@ -211,6 +211,11 @@ spec:
           imagePullPolicy: {{ .Values.images.airflow.pullPolicy }}
           securityContext: {{ $containerSecurityContextWaitForMigrations | 
nindent 12 }}
           volumeMounts:
+            - name: logs
+              mountPath: "/opt/airflow/logs"
+              {{- if .Values.logs.persistence.subPath }}
+              subPath: {{ .Values.logs.persistence.subPath }}
+              {{- end }}
             {{- include "airflow_config_mount" . | nindent 12 }}
             {{- if .Values.volumeMounts }}
               {{- toYaml .Values.volumeMounts | nindent 12 }}
diff --git a/helm-tests/tests/helm_tests/airflow_core/test_scheduler.py 
b/helm-tests/tests/helm_tests/airflow_core/test_scheduler.py
index 164d4f66ca8..c939161f7a2 100644
--- a/helm-tests/tests/helm_tests/airflow_core/test_scheduler.py
+++ b/helm-tests/tests/helm_tests/airflow_core/test_scheduler.py
@@ -99,6 +99,37 @@ class TestScheduler:
         )
         assert actual is None
 
+    @pytest.mark.parametrize(
+        ("logs_values", "expect_sub_path"),
+        [
+            ({"persistence": {"enabled": False}}, None),
+            ({"persistence": {"enabled": True, "subPath": "test/logs"}}, 
"test/logs"),
+        ],
+    )
+    def test_logs_mount_on_wait_for_migrations_initcontainer(self, 
logs_values, expect_sub_path):
+        docs = render_chart(
+            values={
+                "logs": logs_values,
+            },
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
+        )
+
+        mounts = jmespath.search(
+            
"spec.template.spec.initContainers[?name=='wait-for-airflow-migrations'] | 
[0].volumeMounts",
+            docs[0],
+        )
+        assert mounts is not None, (
+            "wait-for-airflow-migrations initContainer not found or has no 
volumeMounts"
+        )
+        assert any(m.get("name") == "logs" and m.get("mountPath") == 
"/opt/airflow/logs" for m in mounts)
+        if expect_sub_path is not None:
+            assert any(
+                m.get("name") == "logs"
+                and m.get("mountPath") == "/opt/airflow/logs"
+                and m.get("subPath") == expect_sub_path
+                for m in mounts
+            )
+
     def test_should_add_extra_init_containers(self):
         docs = render_chart(
             values={
diff --git a/helm-tests/tests/helm_tests/airflow_core/test_triggerer.py 
b/helm-tests/tests/helm_tests/airflow_core/test_triggerer.py
index 40a8316d12c..b3c9e558816 100644
--- a/helm-tests/tests/helm_tests/airflow_core/test_triggerer.py
+++ b/helm-tests/tests/helm_tests/airflow_core/test_triggerer.py
@@ -89,6 +89,38 @@ class TestTriggerer:
         )
         assert actual is None
 
+    @pytest.mark.parametrize(
+        ("logs_values", "expect_sub_path"),
+        [
+            ({"persistence": {"enabled": False}}, None),
+            ({"persistence": {"enabled": True, "subPath": "test/logs"}}, 
"test/logs"),
+        ],
+    )
+    def test_logs_mount_on_wait_for_migrations_initcontainer(self, 
logs_values, expect_sub_path):
+        docs = render_chart(
+            values={
+                "logs": logs_values,
+                "triggerer": {"enabled": True},
+            },
+            show_only=["templates/triggerer/triggerer-deployment.yaml"],
+        )
+
+        mounts = jmespath.search(
+            
"spec.template.spec.initContainers[?name=='wait-for-airflow-migrations'] | 
[0].volumeMounts",
+            docs[0],
+        )
+        assert mounts is not None, (
+            "wait-for-airflow-migrations initContainer not found or has no 
volumeMounts"
+        )
+        assert any(m.get("name") == "logs" and m.get("mountPath") == 
"/opt/airflow/logs" for m in mounts)
+        if expect_sub_path is not None:
+            assert any(
+                m.get("name") == "logs"
+                and m.get("mountPath") == "/opt/airflow/logs"
+                and m.get("subPath") == expect_sub_path
+                for m in mounts
+            )
+
     def test_should_add_extra_containers(self):
         docs = render_chart(
             values={
diff --git a/helm-tests/tests/helm_tests/airflow_core/test_worker.py 
b/helm-tests/tests/helm_tests/airflow_core/test_worker.py
index dce12ded68b..4b5b74ef560 100644
--- a/helm-tests/tests/helm_tests/airflow_core/test_worker.py
+++ b/helm-tests/tests/helm_tests/airflow_core/test_worker.py
@@ -128,6 +128,38 @@ class TestWorker:
         )
         assert actual is None
 
+    @pytest.mark.parametrize(
+        ("logs_values", "expect_sub_path"),
+        [
+            ({"persistence": {"enabled": False}}, None),
+            ({"persistence": {"enabled": True, "subPath": "test/logs"}}, 
"test/logs"),
+        ],
+    )
+    def test_logs_mount_on_wait_for_migrations_initcontainer(self, 
logs_values, expect_sub_path):
+        docs = render_chart(
+            values={
+                "executor": "CeleryExecutor",
+                "logs": logs_values,
+            },
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+
+        mounts = jmespath.search(
+            
"spec.template.spec.initContainers[?name=='wait-for-airflow-migrations'] | 
[0].volumeMounts",
+            docs[0],
+        )
+        assert mounts is not None, (
+            "wait-for-airflow-migrations initContainer not found or has no 
volumeMounts"
+        )
+        assert any(m.get("name") == "logs" and m.get("mountPath") == 
"/opt/airflow/logs" for m in mounts)
+        if expect_sub_path is not None:
+            assert any(
+                m.get("name") == "logs"
+                and m.get("mountPath") == "/opt/airflow/logs"
+                and m.get("subPath") == expect_sub_path
+                for m in mounts
+            )
+
     def test_should_add_extra_init_containers(self):
         docs = render_chart(
             values={

Reply via email to