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 8d89f2e179f [chart/v1-2x-test] Add workers.celery.extraInitContainers 
& workers.kubernetes.extraInitContainers (#64741) (#64979)
8d89f2e179f is described below

commit 8d89f2e179f7bbada5290f8b201d8ba67344b066
Author: Jens Scheffler <[email protected]>
AuthorDate: Thu Apr 9 22:03:40 2026 +0200

    [chart/v1-2x-test] Add workers.celery.extraInitContainers & 
workers.kubernetes.extraInitContainers (#64741) (#64979)
    
    * Refactor workers extraInitContainers-related tests
    
    * Add workers.celery.extraInitContainers & 
workers.kubernetes.extraInitContainers
    
    * Add newsfragment
    (cherry picked from commit 52c4d32)
    
    Co-authored-by: Przemysław Mirowski 
<[email protected]>
---
 chart/docs/using-additional-containers.rst         |  2 +-
 chart/files/pod-template-file.kubernetes-helm-yaml |  4 +-
 chart/newsfragments/64741.significant.rst          |  1 +
 chart/templates/NOTES.txt                          |  8 ++
 chart/values.schema.json                           | 18 ++++-
 chart/values.yaml                                  | 10 +++
 .../airflow_aux/test_pod_template_file.py          | 66 +++++++++++-----
 .../tests/helm_tests/airflow_core/test_worker.py   | 87 +++++++++++++++-------
 .../helm_tests/airflow_core/test_worker_sets.py    | 14 ++++
 9 files changed, 162 insertions(+), 48 deletions(-)

diff --git a/chart/docs/using-additional-containers.rst 
b/chart/docs/using-additional-containers.rst
index 958708f1dd2..af339d683ea 100644
--- a/chart/docs/using-additional-containers.rst
+++ b/chart/docs/using-additional-containers.rst
@@ -52,7 +52,7 @@ Init Containers
 ---------------
 
 You can also deploy extra init containers through the ``extraInitContainers`` 
parameter.
-You can define different containers for the scheduler, webserver, api server, 
worker, triggerer, dag processor, create user job and migrate database job pods.
+You can define different containers for the scheduler, webserver/api-server, 
Celery/Kubernetes workers, triggerer, dag processor, create user job and 
migrate database job pods.
 
 For example, an init container that just says hello:
 
diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml 
b/chart/files/pod-template-file.kubernetes-helm-yaml
index e9108745a82..d0279bd3320 100644
--- a/chart/files/pod-template-file.kubernetes-helm-yaml
+++ b/chart/files/pod-template-file.kubernetes-helm-yaml
@@ -52,8 +52,8 @@ spec:
     {{- if and .Values.dags.gitSync.enabled (not 
.Values.dags.persistence.enabled) }}
       {{- include "git_sync_container" (dict "Values" .Values "is_init" "true" 
"Template" .Template) | nindent 4 }}
     {{- end }}
-    {{- if .Values.workers.extraInitContainers }}
-      {{- tpl (toYaml .Values.workers.extraInitContainers) . | nindent 4 }}
+    {{- if or .Values.workers.kubernetes.extraInitContainers 
.Values.workers.extraInitContainers }}
+      {{- tpl (toYaml (.Values.workers.kubernetes.extraInitContainers | 
default .Values.workers.extraInitContainers)) . | nindent 4 }}
     {{- end }}
     {{- if or .Values.workers.kubernetes.kerberosInitContainer.enabled 
.Values.workers.kerberosInitContainer.enabled }}
     - name: kerberos-init
diff --git a/chart/newsfragments/64741.significant.rst 
b/chart/newsfragments/64741.significant.rst
new file mode 100644
index 00000000000..18a90f8f1da
--- /dev/null
+++ b/chart/newsfragments/64741.significant.rst
@@ -0,0 +1 @@
+``workers.extraInitContainers`` field is now deprecated in favor of 
``workers.celery.extraInitContainers`` and 
``workers.kubernetes.extraInitContainers``. Please update your configuration 
accordingly.
diff --git a/chart/templates/NOTES.txt b/chart/templates/NOTES.txt
index 840e55e43ed..654ffc527e2 100644
--- a/chart/templates/NOTES.txt
+++ b/chart/templates/NOTES.txt
@@ -709,6 +709,14 @@ DEPRECATION WARNING:
 
 {{- end }}
 
+{{- if not (empty .Values.workers.extraInitContainers) }}
+
+ DEPRECATION WARNING:
+    `workers.extraInitContainers` has been renamed to 
`workers.celery.extraInitContainers`/`workers.kubernetes.extraInitContainers`.
+    Please change your values as support for the old name will be dropped in a 
future release.
+
+{{- end }}
+
 {{- if not (empty .Values.workers.runtimeClassName) }}
 
  DEPRECATION WARNING:
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 9809be9468b..eda22559b23 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -2301,7 +2301,7 @@
                     }
                 },
                 "extraInitContainers": {
-                    "description": "Add additional init containers into 
Airflow Celery workers and pods created with pod-template-file (templated).",
+                    "description": "Add additional init containers into 
Airflow Celery workers and pods created with pod-template-file (templated) 
(deprecated, use ``workers.celery.extraInitContainers`` and/or 
``workers.kubernetes.extraInitContainers`` instead).",
                     "type": "array",
                     "default": [],
                     "items": {
@@ -3388,6 +3388,14 @@
                                 "$ref": 
"#/definitions/io.k8s.api.core.v1.Container"
                             }
                         },
+                        "extraInitContainers": {
+                            "description": "Add additional init containers 
into Airflow Celery workers (templated).",
+                            "type": "array",
+                            "default": [],
+                            "items": {
+                                "$ref": 
"#/definitions/io.k8s.api.core.v1.Container"
+                            }
+                        },
                         "extraPorts": {
                             "description": "Expose additional ports of Airflow 
Celery worker container.",
                             "type": "array",
@@ -3886,6 +3894,14 @@
                                 "$ref": 
"#/definitions/io.k8s.api.core.v1.Container"
                             }
                         },
+                        "extraInitContainers": {
+                            "description": "Add additional init containers 
into pods created with pod-template-file (templated).",
+                            "type": "array",
+                            "default": [],
+                            "items": {
+                                "$ref": 
"#/definitions/io.k8s.api.core.v1.Container"
+                            }
+                        },
                         "nodeSelector": {
                             "description": "Select certain nodes for pods 
created with pod-template-file.",
                             "type": "object",
diff --git a/chart/values.yaml b/chart/values.yaml
index f4b4499bac2..309b5490951 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -1052,6 +1052,10 @@ workers:
 
   # Add additional init containers into Airflow Celery workers
   # and pods created with pod-template-file (templated).
+  # (deprecated, use
+  #   `workers.celery.extraInitContainers` and/or
+  #   `workers.kubernetes.extraInitContainers`
+  # instead)
   extraInitContainers: []
 
   # Additional volumes and volume mounts attached to the
@@ -1450,6 +1454,9 @@ workers:
     # Launch additional containers into Airflow Celery worker (templated)
     extraContainers: []
 
+    # Add additional init containers into Airflow Celery workers (templated)
+    extraInitContainers: []
+
     # Expose additional ports of Airflow Celery workers. These can be used for 
additional metric collection.
     extraPorts: []
 
@@ -1617,6 +1624,9 @@ workers:
     # container finishes so Airflow can continue the worker shutdown process!
     extraContainers: []
 
+    # Add additional init containers into pods created with pod-template-file 
(templated)
+    extraInitContainers: []
+
     # Select certain nodes for pods created with pod-template-file
     nodeSelector: {}
 
diff --git a/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py 
b/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py
index 70a4f751cb8..82d9bf2fc2c 100644
--- a/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py
+++ b/helm-tests/tests/helm_tests/airflow_aux/test_pod_template_file.py
@@ -1067,38 +1067,68 @@ class TestPodTemplateFile:
         assert "my_annotation" in annotations
         assert "workerPodAnnotations" in annotations["my_annotation"]
 
-    def test_should_add_extra_init_containers(self):
-        docs = render_chart(
-            values={
-                "workers": {
+    @pytest.mark.parametrize(
+        "workers_values",
+        [
+            {
+                "extraInitContainers": [
+                    {"name": "test-init-container", "image": 
"test-registry/test-repo:test-tag"}
+                ]
+            },
+            {
+                "kubernetes": {
                     "extraInitContainers": [
                         {"name": "test-init-container", "image": 
"test-registry/test-repo:test-tag"}
-                    ],
+                    ]
+                }
+            },
+            {
+                "extraInitContainers": [{"name": "test", "image": "repo:tag"}],
+                "kubernetes": {
+                    "extraInitContainers": [
+                        {"name": "test-init-container", "image": 
"test-registry/test-repo:test-tag"}
+                    ]
                 },
             },
+        ],
+    )
+    def test_should_add_extra_init_containers(self, workers_values):
+        docs = render_chart(
+            values={"workers": workers_values},
             show_only=["templates/pod-template-file.yaml"],
             chart_dir=self.temp_chart_dir,
         )
 
-        assert jmespath.search("spec.initContainers[-1]", docs[0]) == {
-            "name": "test-init-container",
-            "image": "test-registry/test-repo:test-tag",
-        }
+        assert jmespath.search("spec.initContainers", docs[0]) == [
+            {
+                "name": "test-init-container",
+                "image": "test-registry/test-repo:test-tag",
+            }
+        ]
 
-    def test_should_template_extra_init_containers(self):
-        docs = render_chart(
-            values={
-                "workers": {
-                    "extraInitContainers": [{"name": "{{ .Release.Name 
}}-test-init-container"}],
-                },
+    @pytest.mark.parametrize(
+        "workers_values",
+        [
+            {"extraInitContainers": [{"name": "{{ .Release.Name 
}}-test-init-container"}]},
+            {"kubernetes": {"extraInitContainers": [{"name": "{{ .Release.Name 
}}-test-init-container"}]}},
+            {
+                "extraInitContainers": [{"name": "container"}],
+                "kubernetes": {"extraInitContainers": [{"name": "{{ 
.Release.Name }}-test-init-container"}]},
             },
+        ],
+    )
+    def test_should_template_extra_init_containers(self, workers_values):
+        docs = render_chart(
+            values={"workers": workers_values},
             show_only=["templates/pod-template-file.yaml"],
             chart_dir=self.temp_chart_dir,
         )
 
-        assert jmespath.search("spec.initContainers[-1]", docs[0]) == {
-            "name": "release-name-test-init-container",
-        }
+        assert jmespath.search("spec.initContainers", docs[0]) == [
+            {
+                "name": "release-name-test-init-container",
+            }
+        ]
 
     @pytest.mark.parametrize(
         "workers_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 09ca0ee151c..9c103af2040 100644
--- a/helm-tests/tests/helm_tests/airflow_core/test_worker.py
+++ b/helm-tests/tests/helm_tests/airflow_core/test_worker.py
@@ -279,36 +279,66 @@ class TestWorker:
                 for m in mounts
             )
 
-    def test_should_add_extra_init_containers(self):
-        docs = render_chart(
-            values={
-                "workers": {
+    @pytest.mark.parametrize(
+        "workers_values",
+        [
+            {
+                "extraInitContainers": [
+                    {"name": "test-init-container", "image": 
"test-registry/test-repo:test-tag"}
+                ]
+            },
+            {
+                "celery": {
                     "extraInitContainers": [
                         {"name": "test-init-container", "image": 
"test-registry/test-repo:test-tag"}
-                    ],
+                    ]
+                }
+            },
+            {
+                "extraInitContainers": [{"name": "container", "image": 
"repo:tag"}],
+                "celery": {
+                    "extraInitContainers": [
+                        {"name": "test-init-container", "image": 
"test-registry/test-repo:test-tag"}
+                    ]
                 },
             },
+        ],
+    )
+    def test_should_add_extra_init_containers(self, workers_values):
+        docs = render_chart(
+            values={"workers": workers_values},
             show_only=["templates/workers/worker-deployment.yaml"],
         )
 
-        assert jmespath.search("spec.template.spec.initContainers[-1]", 
docs[0]) == {
-            "name": "test-init-container",
-            "image": "test-registry/test-repo:test-tag",
-        }
+        # [1:] -> Skipping wait-for-airflow-migrations init container
+        assert jmespath.search("spec.template.spec.initContainers[1:]", 
docs[0]) == [
+            {
+                "name": "test-init-container",
+                "image": "test-registry/test-repo:test-tag",
+            }
+        ]
 
-    def test_should_template_extra_init_containers(self):
-        docs = render_chart(
-            values={
-                "workers": {
-                    "extraInitContainers": [{"name": "{{ .Release.Name 
}}-test-init-container"}],
-                },
+    @pytest.mark.parametrize(
+        "workers_values",
+        [
+            {"extraInitContainers": [{"name": "{{ .Release.Name 
}}-test-init-container"}]},
+            {"celery": {"extraInitContainers": [{"name": "{{ .Release.Name 
}}-test-init-container"}]}},
+            {
+                "extraInitContainers": [{"name": "container"}],
+                "celery": {"extraInitContainers": [{"name": "{{ .Release.Name 
}}-test-init-container"}]},
             },
+        ],
+    )
+    def test_should_template_extra_init_containers(self, workers_values):
+        docs = render_chart(
+            values={"workers": workers_values},
             show_only=["templates/workers/worker-deployment.yaml"],
         )
 
-        assert jmespath.search("spec.template.spec.initContainers[-1]", 
docs[0]) == {
-            "name": "release-name-test-init-container"
-        }
+        # [1:] -> Skipping wait-for-airflow-migrations init container
+        assert jmespath.search("spec.template.spec.initContainers[1:]", 
docs[0]) == [
+            {"name": "release-name-test-init-container"}
+        ]
 
     def test_should_add_extra_volume_and_extra_volume_mount(self):
         docs = render_chart(
@@ -940,19 +970,24 @@ class TestWorker:
         docs = render_chart(
             values={
                 "workers": {
-                    "extraInitContainers": [
-                        {
-                            "name": "test-init-container",
-                            "image": "test-registry/test-repo:test-tag",
-                            "restartPolicy": "Always",
-                        }
-                    ]
+                    "celery": {
+                        "extraInitContainers": [
+                            {
+                                "name": "test-init-container",
+                                "image": "test-registry/test-repo:test-tag",
+                                "restartPolicy": "Always",
+                            }
+                        ]
+                    }
                 },
             },
             show_only=["templates/workers/worker-deployment.yaml"],
         )
 
-        assert 
jmespath.search("spec.template.spec.initContainers[1].restartPolicy", docs[0]) 
== "Always"
+        # [1:] -> Skipping wait-for-airflow-migrations init container
+        assert jmespath.search("spec.template.spec.initContainers[1:] | 
[*].restartPolicy", docs[0]) == [
+            "Always"
+        ]
 
     @pytest.mark.parametrize(
         ("log_values", "expected_volume"),
diff --git a/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py 
b/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py
index d9ad0da0760..898f630ff44 100644
--- a/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py
+++ b/helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py
@@ -2513,6 +2513,20 @@ class TestWorkerSets:
                     ],
                 },
             },
+            {
+                "celery": {
+                    "enableDefault": False,
+                    "extraInitContainers": [{"name": "test", "image": "test"}],
+                    "sets": [
+                        {
+                            "name": "set1",
+                            "extraInitContainers": [
+                                {"name": "{{ .Chart.Name }}", "image": 
"test-registry/test-repo:test-tag"}
+                            ],
+                        }
+                    ],
+                },
+            },
         ],
     )
     def test_overwrite_extra_init_containers(self, workers_values):

Reply via email to