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 51f663d8642 fix(chart): omit api-server spec.replicas when HPA is 
enabled (#63187)
51f663d8642 is described below

commit 51f663d8642d6e298af5906283871281d85926af
Author: Josef Kolář <[email protected]>
AuthorDate: Wed Mar 11 23:42:39 2026 +0100

    fix(chart): omit api-server spec.replicas when HPA is enabled (#63187)
---
 .../api-server/api-server-deployment.yaml          |  2 ++
 chart/values.schema.json                           |  7 ++++--
 chart/values.yaml                                  |  5 ++--
 .../helm_tests/apiserver/test_hpa_apiserver.py     | 27 ++++++++++++++++++----
 4 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/chart/templates/api-server/api-server-deployment.yaml 
b/chart/templates/api-server/api-server-deployment.yaml
index 4de80ded6ca..29a84c74ed5 100644
--- a/chart/templates/api-server/api-server-deployment.yaml
+++ b/chart/templates/api-server/api-server-deployment.yaml
@@ -47,7 +47,9 @@ metadata:
   annotations: {{- toYaml .Values.apiServer.annotations | nindent 4 }}
   {{- end }}
 spec:
+  {{- if not .Values.apiServer.hpa.enabled }}
   replicas: {{ .Values.apiServer.replicas }}
+  {{- end }}
   {{- if ne $revisionHistoryLimit "" }}
   revisionHistoryLimit: {{ $revisionHistoryLimit }}
   {{- end }}
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 18f2edef8b9..e4d86add20e 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -6179,8 +6179,11 @@
                     }
                 },
                 "replicas": {
-                    "description": "How many Airflow API server replicas 
should run. This setting is ignored when HPA (Horizontal Pod Autoscaler) is 
enabled",
-                    "type": "integer",
+                    "description": "How many Airflow API server replicas 
should run. Omitted from the Deployment, when HPA is enabled.",
+                    "type": [
+                        "integer",
+                        "null"
+                    ],
                     "default": 1
                 },
                 "revisionHistoryLimit": {
diff --git a/chart/values.yaml b/chart/values.yaml
index 3c405709c7a..575e76aef58 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -1748,9 +1748,8 @@ migrateDatabaseJob:
 
 apiServer:
   enabled: true
-  # Number of Airflow API servers in the deployment
-  # This setting is ignored when HPA (Horizontal Pod Autoscaler) is enabled,
-  # as HPA will automatically manage the number of replicas based on the 
configured metrics.
+  # Number of Airflow API servers in the deployment.
+  # Omitted from the Deployment, when HPA is enabled.
   replicas: 1
   # Max number of old replicasets to retain
   revisionHistoryLimit: ~
diff --git a/helm-tests/tests/helm_tests/apiserver/test_hpa_apiserver.py 
b/helm-tests/tests/helm_tests/apiserver/test_hpa_apiserver.py
index b87d326a32c..2adfc49cfcd 100644
--- a/helm-tests/tests/helm_tests/apiserver/test_hpa_apiserver.py
+++ b/helm-tests/tests/helm_tests/apiserver/test_hpa_apiserver.py
@@ -32,10 +32,32 @@ class TestAPIServerHPA:
         )
         assert docs == []
 
+    def test_replicas_omitted_when_null(self):
+        """When apiServer.replicas is null the Deployment must not contain 
spec.replicas."""
+        docs = render_chart(
+            values={
+                "apiServer": {
+                    "replicas": None,
+                    "hpa": {"enabled": True},
+                },
+            },
+            show_only=["templates/api-server/api-server-deployment.yaml"],
+        )
+        assert jmespath.search("spec.replicas", docs[0]) is None
+
+    def test_replicas_present_when_set(self):
+        """When apiServer.replicas is a number the Deployment must contain 
spec.replicas."""
+        docs = render_chart(
+            values={
+                "apiServer": {"replicas": 3},
+            },
+            show_only=["templates/api-server/api-server-deployment.yaml"],
+        )
+        assert jmespath.search("spec.replicas", docs[0]) == 3
+
     def test_should_add_component_specific_labels(self):
         docs = render_chart(
             values={
-                "airflowVersion": "3.0.2",
                 "apiServer": {
                     "hpa": {"enabled": True},
                     "labels": {"test_label": "test_label_value"},
@@ -58,7 +80,6 @@ class TestAPIServerHPA:
         """Verify minimum and maximum replicas."""
         docs = render_chart(
             values={
-                "airflowVersion": "3.0.2",
                 "apiServer": {
                     "hpa": {
                         "enabled": True,
@@ -82,7 +103,6 @@ class TestAPIServerHPA:
         }
         docs = render_chart(
             values={
-                "airflowVersion": "3.0.2",
                 "apiServer": {
                     "hpa": {
                         "enabled": True,
@@ -129,7 +149,6 @@ class TestAPIServerHPA:
     def test_should_use_hpa_metrics(self, metrics, expected_metrics):
         docs = render_chart(
             values={
-                "airflowVersion": "3.0.2",
                 "apiServer": {
                     "hpa": {"enabled": True, **({"metrics": metrics} if 
metrics else {})},
                 },

Reply via email to