Skip to content

Commit 8c1d4cc

Browse files
authored
Add workers.celery.waitForMigrations section (#62054)
* Add workers.celery.waitForMigrations * Add newsfragment
1 parent d9baf3e commit 8c1d4cc

7 files changed

Lines changed: 240 additions & 39 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``workers.waitForMigrations`` section is now deprecated in favor of ``workers.celery.waitForMigrations``. Please update your configuration accordingly.

chart/templates/NOTES.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,30 @@ DEPRECATION WARNING:
685685

686686
{{- end }}
687687

688+
{{- if not .Values.workers.waitForMigrations.enabled }}
689+
690+
DEPRECATION WARNING:
691+
`workers.waitForMigrations.enabled` has been renamed to `workers.celery.waitForMigrations.enabled`.
692+
Please change your values as support for the old name will be dropped in a future release.
693+
694+
{{- end }}
695+
696+
{{- if not (empty .Values.workers.waitForMigrations.env) }}
697+
698+
DEPRECATION WARNING:
699+
`workers.waitForMigrations.env` has been renamed to `workers.celery.waitForMigrations.env`.
700+
Please change your values as support for the old name will be dropped in a future release.
701+
702+
{{- end }}
703+
704+
{{- if not (empty .Values.workers.waitForMigrations.securityContexts.container) }}
705+
706+
DEPRECATION WARNING:
707+
`workers.waitForMigrations.securityContexts.container` has been renamed to `workers.celery.waitForMigrations.securityContexts.container`.
708+
Please change your values as support for the old name will be dropped in a future release.
709+
710+
{{- end }}
711+
688712
{{- if not (empty .Values.webserver.defaultUser) }}
689713

690714
DEPRECATION WARNING:

chart/values.schema.json

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,17 +2520,17 @@
25202520
}
25212521
},
25222522
"waitForMigrations": {
2523-
"description": "Configuration of wait-for-airflow-migration init container for Airflow Celery workers.",
2523+
"description": "Configuration of wait-for-airflow-migration init container for Airflow Celery workers (deprecated, use ``workers.celery.waitForMigrations`` instead).",
25242524
"type": "object",
25252525
"additionalProperties": false,
25262526
"properties": {
25272527
"enabled": {
2528-
"description": "Enable wait-for-airflow-migrations init container.",
2528+
"description": "Enable wait-for-airflow-migrations init container (deprecated, use ``workers.celery.waitForMigrations.enabled`` instead).",
25292529
"type": "boolean",
25302530
"default": true
25312531
},
25322532
"env": {
2533-
"description": "Add additional env vars to wait-for-airflow-migrations init container.",
2533+
"description": "Add additional env vars to wait-for-airflow-migrations init container (deprecated, use ``workers.celery.waitForMigrations.env`` instead).",
25342534
"type": "array",
25352535
"default": [],
25362536
"items": {
@@ -2551,12 +2551,12 @@
25512551
}
25522552
},
25532553
"securityContexts": {
2554-
"description": "Security context definition for the wait-for-airflow-migrations container. If not set, the values from global `securityContexts` will be used.",
2554+
"description": "Security context definition for the wait-for-airflow-migrations container (deprecated, use ``workers.celery.waitForMigrations.securityContexts`` instead). If not set, the values from global `securityContexts` will be used.",
25552555
"type": "object",
25562556
"x-docsSection": "Kubernetes",
25572557
"properties": {
25582558
"container": {
2559-
"description": "Container security context definition for the wait-for-airflow-migrations container.",
2559+
"description": "Container security context definition for the wait-for-airflow-migrations container (deprecated, use ``workers.celery.waitForMigrations.securityContexts.container`` instead).",
25602560
"type": "object",
25612561
"$ref": "#/definitions/io.k8s.api.core.v1.SecurityContext",
25622562
"default": {},
@@ -3348,6 +3348,66 @@
33483348
}
33493349
]
33503350
},
3351+
"waitForMigrations": {
3352+
"description": "Configuration of wait-for-airflow-migration init container for Airflow Celery workers.",
3353+
"type": "object",
3354+
"additionalProperties": false,
3355+
"properties": {
3356+
"enabled": {
3357+
"description": "Whether to create init container to wait for db migrations.",
3358+
"type": [
3359+
"boolean",
3360+
"null"
3361+
],
3362+
"default": null
3363+
},
3364+
"env": {
3365+
"description": "Add additional env vars to wait-for-airflow-migrations init container.",
3366+
"type": "array",
3367+
"default": [],
3368+
"items": {
3369+
"type": "object",
3370+
"properties": {
3371+
"name": {
3372+
"type": "string"
3373+
},
3374+
"value": {
3375+
"type": "string"
3376+
}
3377+
},
3378+
"required": [
3379+
"name",
3380+
"value"
3381+
],
3382+
"additionalProperties": false
3383+
}
3384+
},
3385+
"securityContexts": {
3386+
"description": "Security context definition for the wait-for-airflow-migrations container. If not set, the values from ``workers.waitForMigrations.securityContexts`` will be used.",
3387+
"type": "object",
3388+
"x-docsSection": "Kubernetes",
3389+
"properties": {
3390+
"container": {
3391+
"description": "Container security context definition for the wait-for-airflow-migrations container.",
3392+
"type": "object",
3393+
"$ref": "#/definitions/io.k8s.api.core.v1.SecurityContext",
3394+
"default": {},
3395+
"x-docsSection": "Kubernetes",
3396+
"examples": [
3397+
{
3398+
"allowPrivilegeEscalation": false,
3399+
"capabilities": {
3400+
"drop": [
3401+
"ALL"
3402+
]
3403+
}
3404+
}
3405+
]
3406+
}
3407+
}
3408+
}
3409+
}
3410+
},
33513411
"volumeClaimTemplates": {
33523412
"description": "Specify additional volume claim template for Airflow Celery workers.",
33533413
"type": "array",

chart/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,14 +1136,19 @@ workers:
11361136
env: []
11371137

11381138
# Configuration of wait-for-airflow-migration init container for Airflow Celery workers
1139+
# (deprecated, use `workers.celery.waitForMigrations` instead)
11391140
waitForMigrations:
11401141
# Whether to create init container to wait for db migrations
1142+
# (deprecated, use `workers.celery.waitForMigrations.enabled` instead)
11411143
enabled: true
11421144

1145+
# (deprecated, use `workers.celery.waitForMigrations.env` instead)
11431146
env: []
11441147

11451148
# Detailed default security context for wait-for-airflow-migrations container
1149+
# (deprecated, use `workers.celery.waitForMigrations.securityContexts` instead)
11461150
securityContexts:
1151+
# (deprecated, use `workers.celery.waitForMigrations.securityContexts.container` instead)
11471152
container: {}
11481153

11491154
# Additional env variable configuration for Airflow Celery workers and pods created with pod-template-file
@@ -1404,6 +1409,17 @@ workers:
14041409
# hostnames:
14051410
# - "test.hostname.two"
14061411

1412+
# Configuration of wait-for-airflow-migration init container for Airflow Celery workers
1413+
waitForMigrations:
1414+
# Whether to create init container to wait for db migrations
1415+
enabled: ~
1416+
1417+
env: []
1418+
1419+
# Detailed default security context for wait-for-airflow-migrations container
1420+
securityContexts:
1421+
container: {}
1422+
14071423
# Additional volume claim templates for Airflow Celery workers.
14081424
# Requires mounting of specified volumes under extraVolumeMounts.
14091425
volumeClaimTemplates: []

helm-tests/tests/helm_tests/airflow_core/test_worker.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,16 @@ def test_should_template_extra_containers(self):
203203
"name": "release-name-test-container"
204204
}
205205

206-
def test_disable_wait_for_migration(self):
206+
@pytest.mark.parametrize(
207+
"workers_values",
208+
[
209+
{"waitForMigrations": {"enabled": False}},
210+
{"celery": {"waitForMigrations": {"enabled": False}}},
211+
],
212+
)
213+
def test_disable_wait_for_migration(self, workers_values):
207214
docs = render_chart(
208-
values={
209-
"workers": {
210-
"waitForMigrations": {"enabled": False},
211-
},
212-
},
215+
values={"workers": workers_values},
213216
show_only=["templates/workers/worker-deployment.yaml"],
214217
)
215218
actual = jmespath.search(
@@ -362,13 +365,20 @@ def test_should_add_extraEnvs(self):
362365
"valueFrom": {"configMapKeyRef": {"name": "my-config-map", "key": "my-key"}},
363366
} in jmespath.search("spec.template.spec.containers[0].env", docs[0])
364367

365-
def test_should_add_extraEnvs_to_wait_for_migration_container(self):
366-
docs = render_chart(
367-
values={
368-
"workers": {
369-
"waitForMigrations": {"env": [{"name": "TEST_ENV_1", "value": "test_env_1"}]},
370-
},
368+
@pytest.mark.parametrize(
369+
"workers_values",
370+
[
371+
{"waitForMigrations": {"env": [{"name": "TEST_ENV_1", "value": "test_env_1"}]}},
372+
{"celery": {"waitForMigrations": {"env": [{"name": "TEST_ENV_1", "value": "test_env_1"}]}}},
373+
{
374+
"waitForMigrations": {"env": [{"name": "TEST", "value": "test"}]},
375+
"celery": {"waitForMigrations": {"env": [{"name": "TEST_ENV_1", "value": "test_env_1"}]}},
371376
},
377+
],
378+
)
379+
def test_should_add_extraEnvs_to_wait_for_migration_container(self, workers_values):
380+
docs = render_chart(
381+
values={"workers": workers_values},
372382
show_only=["templates/workers/worker-deployment.yaml"],
373383
)
374384

helm-tests/tests/helm_tests/airflow_core/test_worker_sets.py

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,16 +2866,27 @@ def test_overwrite_labels(self, workers_values):
28662866
assert labels["test"] == "echo"
28672867
assert labels.get("echo") is None
28682868

2869-
def test_overwrite_wait_for_migration_disable(self):
2870-
docs = render_chart(
2871-
values={
2872-
"workers": {
2873-
"celery": {
2874-
"enableDefault": False,
2875-
"sets": [{"name": "set1", "waitForMigrations": {"enabled": False}}],
2876-
},
2877-
},
2869+
@pytest.mark.parametrize(
2870+
"workers_values",
2871+
[
2872+
{
2873+
"celery": {
2874+
"enableDefault": False,
2875+
"sets": [{"name": "set1", "waitForMigrations": {"enabled": False}}],
2876+
}
28782877
},
2878+
{
2879+
"celery": {
2880+
"waitForMigrations": {"enabled": True},
2881+
"enableDefault": False,
2882+
"sets": [{"name": "set1", "waitForMigrations": {"enabled": False}}],
2883+
}
2884+
},
2885+
],
2886+
)
2887+
def test_overwrite_wait_for_migration_disable(self, workers_values):
2888+
docs = render_chart(
2889+
values={"workers": workers_values},
28792890
show_only=["templates/workers/worker-deployment.yaml"],
28802891
)
28812892
assert (
@@ -2885,17 +2896,28 @@ def test_overwrite_wait_for_migration_disable(self):
28852896
is None
28862897
)
28872898

2888-
def test_overwrite_wait_for_migration_enable(self):
2889-
docs = render_chart(
2890-
values={
2891-
"workers": {
2892-
"waitForMigrations": {"enabled": False},
2893-
"celery": {
2894-
"enableDefault": False,
2895-
"sets": [{"name": "set1", "waitForMigrations": {"enabled": True}}],
2896-
},
2899+
@pytest.mark.parametrize(
2900+
"workers_values",
2901+
[
2902+
{
2903+
"waitForMigrations": {"enabled": False},
2904+
"celery": {
2905+
"enableDefault": False,
2906+
"sets": [{"name": "set1", "waitForMigrations": {"enabled": True}}],
28972907
},
28982908
},
2909+
{
2910+
"celery": {
2911+
"waitForMigrations": {"enabled": False},
2912+
"enableDefault": False,
2913+
"sets": [{"name": "set1", "waitForMigrations": {"enabled": True}}],
2914+
}
2915+
},
2916+
],
2917+
)
2918+
def test_overwrite_wait_for_migration_enable(self, workers_values):
2919+
docs = render_chart(
2920+
values={"workers": workers_values},
28992921
show_only=["templates/workers/worker-deployment.yaml"],
29002922
)
29012923
assert (
@@ -2924,6 +2946,18 @@ def test_overwrite_wait_for_migration_enable(self):
29242946
],
29252947
},
29262948
},
2949+
{
2950+
"celery": {
2951+
"waitForMigrations": {"env": [{"name": "TEST", "value": "test"}]},
2952+
"enableDefault": False,
2953+
"sets": [
2954+
{
2955+
"name": "set1",
2956+
"waitForMigrations": {"env": [{"name": "TEST_ENV_1", "value": "test_env_1"}]},
2957+
}
2958+
],
2959+
},
2960+
},
29272961
],
29282962
)
29292963
def test_overwrite_wait_for_migration_env(self, workers_values):
@@ -2960,6 +2994,20 @@ def test_overwrite_wait_for_migration_env(self, workers_values):
29602994
],
29612995
},
29622996
},
2997+
{
2998+
"celery": {
2999+
"waitForMigrations": {
3000+
"securityContexts": {"container": {"allowPrivilegeEscalation": False}}
3001+
},
3002+
"enableDefault": False,
3003+
"sets": [
3004+
{
3005+
"name": "set1",
3006+
"waitForMigrations": {"securityContexts": {"container": {"runAsUser": 10}}},
3007+
}
3008+
],
3009+
},
3010+
},
29633011
],
29643012
)
29653013
def test_overwrite_wait_for_migration_security_context_container(self, workers_values):

0 commit comments

Comments
 (0)