Skip to content

Commit 0dad3b4

Browse files
committed
fix(chart): omit api-server spec.replicas when HPA is enabled
1 parent a26de21 commit 0dad3b4

4 files changed

Lines changed: 33 additions & 9 deletions

File tree

chart/templates/api-server/api-server-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ metadata:
4747
annotations: {{- toYaml .Values.apiServer.annotations | nindent 4 }}
4848
{{- end }}
4949
spec:
50+
{{- if not .Values.apiServer.hpa.enabled }}
5051
replicas: {{ .Values.apiServer.replicas }}
52+
{{- end }}
5153
{{- if ne $revisionHistoryLimit "" }}
5254
revisionHistoryLimit: {{ $revisionHistoryLimit }}
5355
{{- end }}

chart/values.schema.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6179,8 +6179,11 @@
61796179
}
61806180
},
61816181
"replicas": {
6182-
"description": "How many Airflow API server replicas should run. This setting is ignored when HPA (Horizontal Pod Autoscaler) is enabled",
6183-
"type": "integer",
6182+
"description": "How many Airflow API server replicas should run. Set to null (~) when HPA is enabled to omit the field from the Deployment and let HPA exclusively control the replica count.",
6183+
"type": [
6184+
"integer",
6185+
"null"
6186+
],
61846187
"default": 1
61856188
},
61866189
"revisionHistoryLimit": {

chart/values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,9 +1748,9 @@ migrateDatabaseJob:
17481748

17491749
apiServer:
17501750
enabled: true
1751-
# Number of Airflow API servers in the deployment
1752-
# This setting is ignored when HPA (Horizontal Pod Autoscaler) is enabled,
1753-
# as HPA will automatically manage the number of replicas based on the configured metrics.
1751+
# Number of Airflow API servers in the deployment.
1752+
# Set to ~ (null) when HPA is enabled so the replicas field is omitted from the Deployment,
1753+
# letting HPA exclusively control the replica count.
17541754
replicas: 1
17551755
# Max number of old replicasets to retain
17561756
revisionHistoryLimit: ~

helm-tests/tests/helm_tests/apiserver/test_hpa_apiserver.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,32 @@ def test_hpa_disabled_by_default(self):
3232
)
3333
assert docs == []
3434

35+
def test_replicas_omitted_when_null(self):
36+
"""When apiServer.replicas is null the Deployment must not contain spec.replicas."""
37+
docs = render_chart(
38+
values={
39+
"apiServer": {
40+
"replicas": None,
41+
"hpa": {"enabled": True},
42+
},
43+
},
44+
show_only=["templates/api-server/api-server-deployment.yaml"],
45+
)
46+
assert jmespath.search("spec.replicas", docs[0]) is None
47+
48+
def test_replicas_present_when_set(self):
49+
"""When apiServer.replicas is a number the Deployment must contain spec.replicas."""
50+
docs = render_chart(
51+
values={
52+
"apiServer": {"replicas": 3},
53+
},
54+
show_only=["templates/api-server/api-server-deployment.yaml"],
55+
)
56+
assert jmespath.search("spec.replicas", docs[0]) == 3
57+
3558
def test_should_add_component_specific_labels(self):
3659
docs = render_chart(
3760
values={
38-
"airflowVersion": "3.0.2",
3961
"apiServer": {
4062
"hpa": {"enabled": True},
4163
"labels": {"test_label": "test_label_value"},
@@ -58,7 +80,6 @@ def test_min_max_replicas(self, min_replicas, max_replicas):
5880
"""Verify minimum and maximum replicas."""
5981
docs = render_chart(
6082
values={
61-
"airflowVersion": "3.0.2",
6283
"apiServer": {
6384
"hpa": {
6485
"enabled": True,
@@ -82,7 +103,6 @@ def test_hpa_behavior(self):
82103
}
83104
docs = render_chart(
84105
values={
85-
"airflowVersion": "3.0.2",
86106
"apiServer": {
87107
"hpa": {
88108
"enabled": True,
@@ -129,7 +149,6 @@ def test_hpa_behavior(self):
129149
def test_should_use_hpa_metrics(self, metrics, expected_metrics):
130150
docs = render_chart(
131151
values={
132-
"airflowVersion": "3.0.2",
133152
"apiServer": {
134153
"hpa": {"enabled": True, **({"metrics": metrics} if metrics else {})},
135154
},

0 commit comments

Comments
 (0)