Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1172,3 +1172,23 @@ This helper function returns true if the executor can launch pods (Kubernetes-ba
{{- print "true" -}}
{{- end -}}
{{- end -}}

{{/*
Get revisionHistoryLimit with nil-aware fallback.
Unlike `or`, this properly handles 0 as a valid value.
Pass a list of values to check in order of priority.

Usage:
include "airflow.revisionHistoryLimit" (list .Values.scheduler.revisionHistoryLimit .Values.revisionHistoryLimit)
*/}}
{{- define "airflow.revisionHistoryLimit" -}}
{{- $result := "" -}}
{{- $found := false -}}
{{- range . -}}
{{- if and (not $found) (not (kindIs "invalid" .)) -}}
{{- $result = . -}}
{{- $found = true -}}
{{- end -}}
{{- end -}}
{{- $result -}}
{{- end -}}
4 changes: 2 additions & 2 deletions chart/templates/api-server/api-server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{- $affinity := or .Values.apiServer.affinity .Values.affinity }}
{{- $tolerations := or .Values.apiServer.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.apiServer.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.apiServer.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.apiServer.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "airflowPodSecurityContext" (list . .Values.apiServer) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.apiServer) }}
{{- $containerSecurityContextWaitForMigrations := include "containerSecurityContext" (list . .Values.apiServer.waitForMigrations) }}
Expand All @@ -48,7 +48,7 @@ metadata:
{{- end }}
spec:
replicas: {{ .Values.apiServer.replicas }}
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
strategy:
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/dag-processor/dag-processor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{{- $affinity := or .Values.dagProcessor.affinity .Values.affinity }}
{{- $tolerations := or .Values.dagProcessor.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.dagProcessor.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.dagProcessor.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.dagProcessor.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "airflowPodSecurityContext" (list . .Values.dagProcessor) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.dagProcessor) }}
{{- $containerSecurityContextLogGroomerSidecar := include "containerSecurityContext" (list . .Values.dagProcessor.logGroomerSidecar) }}
Expand All @@ -54,7 +54,7 @@ metadata:
{{- end }}
spec:
replicas: {{ .Values.dagProcessor.replicas }}
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
selector:
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/flower/flower-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{{- $affinity := or .Values.flower.affinity .Values.affinity }}
{{- $tolerations := or .Values.flower.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.flower.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.flower.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.flower.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "airflowPodSecurityContext" (list . .Values.flower) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.flower) }}
{{- $containerLifecycleHooks := or .Values.flower.containerLifecycleHooks .Values.containerLifecycleHooks }}
Expand All @@ -48,7 +48,7 @@ metadata:
{{- end }}
spec:
replicas: 1
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
selector:
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/pgbouncer/pgbouncer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{- $affinity := or .Values.pgbouncer.affinity .Values.affinity }}
{{- $tolerations := or .Values.pgbouncer.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.pgbouncer.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.pgbouncer.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.pgbouncer.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "localPodSecurityContext" .Values.pgbouncer }}
{{- $containerSecurityContext := include "externalContainerSecurityContext" .Values.pgbouncer }}
{{- $containerSecurityContextMetricsExporter := include "externalContainerSecurityContext" .Values.pgbouncer.metricsExporterSidecar }}
Expand All @@ -49,7 +49,7 @@ metadata:
{{- end }}
spec:
replicas: {{ .Values.pgbouncer.replicas | default "1" }}
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
strategy:
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{{- $affinity := or .Values.scheduler.affinity .Values.affinity }}
{{- $tolerations := or .Values.scheduler.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.scheduler.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.scheduler.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.scheduler.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "airflowPodSecurityContext" (list . .Values.scheduler) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.scheduler) }}
{{- $containerSecurityContextWaitForMigrations := include "containerSecurityContext" (list . .Values.scheduler.waitForMigrations) }}
Expand Down Expand Up @@ -69,7 +69,7 @@ spec:
serviceName: {{ include "airflow.fullname" . }}-scheduler
{{- end }}
replicas: {{ .Values.scheduler.replicas }}
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
{{- if and $stateful .Values.scheduler.updateStrategy }}
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/statsd/statsd-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{- $affinity := or .Values.statsd.affinity .Values.affinity }}
{{- $tolerations := or .Values.statsd.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.statsd.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.statsd.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.statsd.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "localPodSecurityContext" .Values.statsd }}
{{- $containerSecurityContext := include "externalContainerSecurityContext" .Values.statsd }}
{{- $containerLifecycleHooks := .Values.statsd.containerLifecycleHooks }}
Expand All @@ -47,7 +47,7 @@ metadata:
{{- end }}
spec:
replicas: 1
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
selector:
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/triggerer/triggerer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{{- $affinity := or .Values.triggerer.affinity .Values.affinity }}
{{- $tolerations := or .Values.triggerer.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.triggerer.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.triggerer.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.triggerer.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "airflowPodSecurityContext" (list . .Values.triggerer) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.triggerer) }}
{{- $containerSecurityContextWaitForMigrations := include "containerSecurityContext" (list . .Values.triggerer.waitForMigrations) }}
Expand Down Expand Up @@ -59,7 +59,7 @@ spec:
{{- if not $keda }}
replicas: {{ .Values.triggerer.replicas }}
{{- end }}
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
selector:
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/webserver/webserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{- $affinity := or .Values.webserver.affinity .Values.affinity }}
{{- $tolerations := or .Values.webserver.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.webserver.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.webserver.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.webserver.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "airflowPodSecurityContext" (list . .Values.webserver) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.webserver) }}
{{- $containerSecurityContextWaitForMigrations := include "containerSecurityContext" (list . .Values.webserver.waitForMigrations) }}
Expand All @@ -50,7 +50,7 @@ spec:
{{- if not .Values.webserver.hpa.enabled }}
replicas: {{ .Values.webserver.replicas }}
{{- end}}
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
strategy:
Expand Down
4 changes: 2 additions & 2 deletions chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{{- $affinity := or .Values.workers.affinity .Values.affinity }}
{{- $tolerations := or .Values.workers.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.workers.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $revisionHistoryLimit := or .Values.workers.celery.revisionHistoryLimit .Values.workers.revisionHistoryLimit .Values.revisionHistoryLimit }}
{{- $revisionHistoryLimit := include "airflow.revisionHistoryLimit" (list .Values.workers.celery.revisionHistoryLimit .Values.workers.revisionHistoryLimit .Values.revisionHistoryLimit) }}
{{- $securityContext := include "airflowPodSecurityContext" (list . .Values.workers) }}
{{- $containerSecurityContext := include "containerSecurityContext" (list . .Values.workers) }}
{{- $containerSecurityContextPersistence := include "containerSecurityContext" (list . .Values.workers.persistence) }}
Expand Down Expand Up @@ -65,7 +65,7 @@ spec:
{{- if and (not $keda) (not $hpa) }}
replicas: {{ .Values.workers.celery.replicas | default .Values.workers.replicas }}
{{- end }}
{{- if $revisionHistoryLimit }}
{{- if ne $revisionHistoryLimit "" }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
{{- if and $persistence (or .Values.workers.celery.persistence.persistentVolumeClaimRetentionPolicy .Values.workers.persistence.persistentVolumeClaimRetentionPolicy) }}
Expand Down
19 changes: 19 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ def test_revision_history_limit(self, revision_history_limit, global_revision_hi
expected_result = revision_history_limit if revision_history_limit else global_revision_history_limit
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result

@pytest.mark.parametrize(
("revision_history_limit", "global_revision_history_limit", "expected"),
[(0, None, 0), (None, 0, 0), (0, 10, 0)],
)
def test_revision_history_limit_zero(
self, revision_history_limit, global_revision_history_limit, expected
):
"""Test that revisionHistoryLimit can be set to 0."""
values = {"apiServer": {}}
if revision_history_limit is not None:
values["apiServer"]["revisionHistoryLimit"] = revision_history_limit
if global_revision_history_limit is not None:
values["revisionHistoryLimit"] = global_revision_history_limit
docs = render_chart(
values=values,
show_only=["templates/api-server/api-server-deployment.yaml"],
)
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

def test_should_add_scheme_to_liveness_and_readiness_and_startup_probes(self):
docs = render_chart(
values={
Expand Down
19 changes: 19 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_dag_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,25 @@ def test_revision_history_limit(self, revision_history_limit, global_revision_hi
expected_result = revision_history_limit or global_revision_history_limit
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result

@pytest.mark.parametrize(
("revision_history_limit", "global_revision_history_limit", "expected"),
[(0, None, 0), (None, 0, 0), (0, 10, 0)],
)
def test_revision_history_limit_zero(
self, revision_history_limit, global_revision_history_limit, expected
):
"""Test that revisionHistoryLimit can be set to 0."""
values = {"dagProcessor": {"enabled": True}}
if revision_history_limit is not None:
values["dagProcessor"]["revisionHistoryLimit"] = revision_history_limit
if global_revision_history_limit is not None:
values["revisionHistoryLimit"] = global_revision_history_limit
docs = render_chart(
values=values,
show_only=["templates/dag-processor/dag-processor-deployment.yaml"],
)
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

@pytest.mark.parametrize("command", [None, ["custom", "command"]])
@pytest.mark.parametrize("args", [None, ["custom", "args"]])
def test_command_and_args_overrides(self, command, args):
Expand Down
19 changes: 19 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,25 @@ def test_revision_history_limit(self, revision_history_limit, global_revision_hi
expected_result = revision_history_limit or global_revision_history_limit
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result

@pytest.mark.parametrize(
("revision_history_limit", "global_revision_history_limit", "expected"),
[(0, None, 0), (None, 0, 0), (0, 10, 0)],
)
def test_revision_history_limit_zero(
self, revision_history_limit, global_revision_history_limit, expected
):
"""Test that revisionHistoryLimit can be set to 0."""
values = {"scheduler": {}}
if revision_history_limit is not None:
values["scheduler"]["revisionHistoryLimit"] = revision_history_limit
if global_revision_history_limit is not None:
values["revisionHistoryLimit"] = global_revision_history_limit
docs = render_chart(
values=values,
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

def test_should_create_valid_affinity_tolerations_and_node_selector(self):
docs = render_chart(
values={
Expand Down
19 changes: 19 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_triggerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ def test_revision_history_limit(self, revision_history_limit, global_revision_hi
expected_result = revision_history_limit or global_revision_history_limit
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result

@pytest.mark.parametrize(
("revision_history_limit", "global_revision_history_limit", "expected"),
[(0, None, 0), (None, 0, 0), (0, 10, 0)],
)
def test_revision_history_limit_zero(
self, revision_history_limit, global_revision_history_limit, expected
):
"""Test that revisionHistoryLimit can be set to 0."""
values = {"triggerer": {"enabled": True}}
if revision_history_limit is not None:
values["triggerer"]["revisionHistoryLimit"] = revision_history_limit
if global_revision_history_limit is not None:
values["revisionHistoryLimit"] = global_revision_history_limit
docs = render_chart(
values=values,
show_only=["templates/triggerer/triggerer-deployment.yaml"],
)
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

def test_disable_wait_for_migration(self):
docs = render_chart(
values={
Expand Down
23 changes: 23 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ def test_revision_history_limit_overwrite(self, worker_values, global_limit, exp

assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

@pytest.mark.parametrize(
("worker_values", "global_limit", "expected"),
[
({}, 0, 0),
({"revisionHistoryLimit": 0}, None, 0),
({"celery": {"revisionHistoryLimit": 0}}, None, 0),
({"revisionHistoryLimit": 0}, 10, 0),
({"celery": {"revisionHistoryLimit": 0}}, 10, 0),
({"revisionHistoryLimit": 0, "celery": {"revisionHistoryLimit": 0}}, 10, 0),
],
)
def test_revision_history_limit_zero(self, worker_values, global_limit, expected):
"""Test that revisionHistoryLimit can be set to 0."""
values = {"workers": worker_values}
if global_limit is not None:
values["revisionHistoryLimit"] = global_limit
docs = render_chart(
values=values,
show_only=["templates/workers/worker-deployment.yaml"],
)

assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

def test_should_add_extra_containers(self):
docs = render_chart(
values={
Expand Down
19 changes: 19 additions & 0 deletions helm-tests/tests/helm_tests/other/test_flower.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ def test_revision_history_limit(self, revision_history_limit, global_revision_hi
expected_result = revision_history_limit or global_revision_history_limit
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result

@pytest.mark.parametrize(
("revision_history_limit", "global_revision_history_limit", "expected"),
[(0, None, 0), (None, 0, 0), (0, 10, 0)],
)
def test_revision_history_limit_zero(
self, revision_history_limit, global_revision_history_limit, expected
):
"""Test that revisionHistoryLimit can be set to 0."""
values = {"flower": {"enabled": True}}
if revision_history_limit is not None:
values["flower"]["revisionHistoryLimit"] = revision_history_limit
if global_revision_history_limit is not None:
values["revisionHistoryLimit"] = global_revision_history_limit
docs = render_chart(
values=values,
show_only=["templates/flower/flower-deployment.yaml"],
)
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

@pytest.mark.parametrize(
("airflow_version", "expected_arg"),
[
Expand Down
19 changes: 19 additions & 0 deletions helm-tests/tests/helm_tests/other/test_pgbouncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@ def test_revision_history_limit(self, revision_history_limit, global_revision_hi
expected_result = revision_history_limit or global_revision_history_limit
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected_result

@pytest.mark.parametrize(
("revision_history_limit", "global_revision_history_limit", "expected"),
[(0, None, 0), (None, 0, 0), (0, 10, 0)],
)
def test_revision_history_limit_zero(
self, revision_history_limit, global_revision_history_limit, expected
):
"""Test that revisionHistoryLimit can be set to 0."""
values = {"pgbouncer": {"enabled": True}}
if revision_history_limit is not None:
values["pgbouncer"]["revisionHistoryLimit"] = revision_history_limit
if global_revision_history_limit is not None:
values["revisionHistoryLimit"] = global_revision_history_limit
docs = render_chart(
values=values,
show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"],
)
assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == expected

def test_scheduler_name(self):
docs = render_chart(
values={"pgbouncer": {"enabled": True}, "schedulerName": "airflow-scheduler"},
Expand Down
Loading