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
2 changes: 1 addition & 1 deletion chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{- $nodeSelector := or .Values.workers.kubernetes.nodeSelector .Values.workers.nodeSelector .Values.nodeSelector }}
{{- $affinity := or .Values.workers.kubernetes.affinity .Values.workers.affinity .Values.affinity }}
{{- $tolerations := or .Values.workers.kubernetes.tolerations .Values.workers.tolerations .Values.tolerations }}
{{- $topologySpreadConstraints := or .Values.workers.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $topologySpreadConstraints := or .Values.workers.kubernetes.topologySpreadConstraints .Values.workers.topologySpreadConstraints .Values.topologySpreadConstraints }}
{{- $securityContext := include "airflowPodSecurityContext" (list .Values.workers.kubernetes .Values.workers .Values) }}
{{- $containerSecurityContextKerberosSidecar := include "containerSecurityContext" (list .Values.workers.kubernetes.kerberosSidecar .Values.workers.kerberosSidecar .Values) }}
{{- $containerLifecycleHooksKerberosSidecar := or .Values.workers.kubernetes.kerberosSidecar.containerLifecycleHooks .Values.workers.kerberosSidecar.containerLifecycleHooks .Values.containerLifecycleHooks }}
Expand Down
1 change: 1 addition & 0 deletions chart/newsfragments/64980.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``workers.topologySpreadConstraints`` field is now deprecated in favor of ``workers.celery.topologySpreadConstraints`` and ``workers.kubernetes.topologySpreadConstraints``. Please update your configuration accordingly.
8 changes: 8 additions & 0 deletions chart/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,14 @@ DEPRECATION WARNING:

{{- end }}

{{- if not (empty .Values.workers.topologySpreadConstraints) }}

DEPRECATION WARNING:
`workers.topologySpreadConstraints` has been renamed to `workers.celery.topologySpreadConstraints`/`workers.kubernetes.topologySpreadConstraints`.
Please change your values as support for the old name will be dropped in a future release.

{{- end }}

{{- if not (empty .Values.workers.nodeSelector) }}

DEPRECATION WARNING:
Expand Down
20 changes: 19 additions & 1 deletion chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2372,7 +2372,7 @@
}
},
"topologySpreadConstraints": {
"description": "Specify topology spread constraints for Airflow Celery worker pods and pods created with pod-template-file.",
"description": "Specify topology spread constraints for Airflow Celery worker pods and pods created with pod-template-file (deprecated, use ``workers.celery.topologySpreadConstraints`` and/or ``workers.kubernetes.topologySpreadConstraints`` instead).",
"type": "array",
"default": [],
"items": {
Expand Down Expand Up @@ -3451,6 +3451,15 @@
"$ref": "#/definitions/io.k8s.api.core.v1.Toleration"
}
},
"topologySpreadConstraints": {
"description": "Specify topology spread constraints for Airflow Celery worker pods.",
"type": "array",
"default": [],
"items": {
"type": "object",
"$ref": "#/definitions/io.k8s.api.core.v1.TopologySpreadConstraint"
}
},
"hostAliases": {
"description": "Specify HostAliases for Airflow Celery worker pods.",
"items": {
Expand Down Expand Up @@ -3966,6 +3975,15 @@
"$ref": "#/definitions/io.k8s.api.core.v1.Toleration"
}
},
"topologySpreadConstraints": {
"description": "Specify topology spread constraints for pods created with pod-template-file.",
"type": "array",
"default": [],
"items": {
"type": "object",
"$ref": "#/definitions/io.k8s.api.core.v1.TopologySpreadConstraint"
}
},
"hostAliases": {
"description": "Specify HostAliases for pods created with pod-template-file.",
"items": {
Expand Down
8 changes: 8 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,10 @@ workers:
# (deprecated, use `workers.celery.tolerations` and/or `workers.kubernetes.tolerations` instead)
tolerations: []

# (deprecated, use
# `workers.celery.topologySpreadConstraints` and/or
# `workers.kubernetes.topologySpreadConstraints`
# instead)
topologySpreadConstraints: []

# hostAliases to use in Airflow Celery worker pods and pods created with pod-template-file
Expand Down Expand Up @@ -1496,6 +1500,8 @@ workers:

tolerations: []

topologySpreadConstraints: []

# hostAliases to use in Airflow Celery worker pods
# See:
# https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/
Expand Down Expand Up @@ -1666,6 +1672,8 @@ workers:

tolerations: []

topologySpreadConstraints: []

# hostAliases to use in pods created with pod-template-file
# See:
# https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,41 @@ def test_workers_tolerations(self, workers_values):
{"key": "dynamic-pods", "operator": "Equal", "value": "true", "effect": "NoSchedule"}
]

def test_workers_topology_spread_constraints(self):
docs = render_chart(
values={
"executor": "KubernetesExecutor",
"workers": {
@pytest.mark.parametrize(
"workers_values",
[
{
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "foo",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
],
},
{
"kubernetes": {
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "foo",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
],
}
},
{
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "not-me",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
],
"kubernetes": {
"topologySpreadConstraints": [
{
"maxSkew": 1,
Expand All @@ -609,6 +639,11 @@ def test_workers_topology_spread_constraints(self):
],
},
},
],
)
def test_workers_topology_spread_constraints(self, workers_values):
docs = render_chart(
values={"executor": "KubernetesExecutor", "workers": workers_values},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)
Expand Down
64 changes: 54 additions & 10 deletions helm-tests/tests/helm_tests/airflow_core/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,23 +706,67 @@ def test_tolerations(self, workers_values):
{"key": "dynamic-pods", "operator": "Equal", "value": "true", "effect": "NoSchedule"}
]

def test_topology_spread_constraints(self):
expected_topology_spread_constraints = [
@pytest.mark.parametrize(
"workers_values",
[
{
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "foo",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
]
},
{
"celery": {
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "foo",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
]
}
},
{
"topologySpreadConstraints": [
{
"maxSkew": 2,
"topologyKey": "not-me",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"airflow": "test"}},
}
],
"celery": {
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "foo",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
]
},
},
],
)
def test_topology_spread_constraints(self, workers_values):
docs = render_chart(
values={"workers": workers_values},
show_only=["templates/workers/worker-deployment.yaml"],
)

assert jmespath.search("spec.template.spec.topologySpreadConstraints", docs[0]) == [
{
"maxSkew": 1,
"topologyKey": "foo",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
]
docs = render_chart(
values={"workers": {"topologySpreadConstraints": expected_topology_spread_constraints}},
show_only=["templates/workers/worker-deployment.yaml"],
)

assert expected_topology_spread_constraints == jmespath.search(
"spec.template.spec.topologySpreadConstraints", docs[0]
)

@pytest.mark.parametrize(
"workers_values",
Expand Down
26 changes: 26 additions & 0 deletions helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2998,6 +2998,32 @@ def test_overwrite_tolerations(self, workers_values):
],
},
},
{
"celery": {
"enableDefault": False,
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "not-me",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
],
"sets": [
{
"name": "set1",
"topologySpreadConstraints": [
{
"maxSkew": 1,
"topologyKey": "foo",
"whenUnsatisfiable": "ScheduleAnyway",
"labelSelector": {"matchLabels": {"tier": "airflow"}},
}
],
}
],
},
},
],
)
def test_overwrite_topology_spread_constraints(self, workers_values):
Expand Down
Loading