This is an automated email from the ASF dual-hosted git repository.
potiuk 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 c4790dfb89 Chart: template dagprocessor waitformigrations
extraVolumeMounts (#32100)
c4790dfb89 is described below
commit c4790dfb89f3bbff9ddc0c72d54a12f9c71b81bb
Author: Aakcht <[email protected]>
AuthorDate: Wed Jun 28 01:52:00 2023 +0300
Chart: template dagprocessor waitformigrations extraVolumeMounts (#32100)
* Chart: template dagprocessor waitformigrations extraVolumeMounts
* Add tests
---------
Co-authored-by: Jed Cunningham
<[email protected]>
---
.../dag-processor/dag-processor-deployment.yaml | 2 +-
tests/charts/airflow_aux/test_create_user_job.py | 8 ++++----
.../charts/airflow_aux/test_migrate_database_job.py | 8 ++++----
tests/charts/airflow_aux/test_pod_template_file.py | 10 ++++++----
tests/charts/airflow_core/test_dag_processor.py | 12 +++++++-----
tests/charts/airflow_core/test_scheduler.py | 13 +++++++++----
tests/charts/airflow_core/test_triggerer.py | 13 +++++++++----
tests/charts/airflow_core/test_worker.py | 13 +++++++++----
tests/charts/other/test_flower.py | 10 ++++++----
tests/charts/other/test_git_sync_scheduler.py | 20 ++++++++++++--------
tests/charts/other/test_pgbouncer.py | 11 +++++++----
tests/charts/webserver/test_webserver.py | 13 +++++++++----
12 files changed, 83 insertions(+), 50 deletions(-)
diff --git a/chart/templates/dag-processor/dag-processor-deployment.yaml
b/chart/templates/dag-processor/dag-processor-deployment.yaml
index 5515ac4b87..0e0e52578a 100644
--- a/chart/templates/dag-processor/dag-processor-deployment.yaml
+++ b/chart/templates/dag-processor/dag-processor-deployment.yaml
@@ -121,7 +121,7 @@ spec:
{{- toYaml .Values.volumeMounts | nindent 12 }}
{{- end }}
{{- if .Values.dagProcessor.extraVolumeMounts }}
- {{- toYaml .Values.dagProcessor.extraVolumeMounts | nindent 12 }}
+ {{- tpl (toYaml .Values.dagProcessor.extraVolumeMounts) . |
nindent 12 }}
{{- end }}
{{- include "airflow_config_mount" . | nindent 12 }}
args: {{- include "wait-for-migrations-command" . | indent 10 }}
diff --git a/tests/charts/airflow_aux/test_create_user_job.py
b/tests/charts/airflow_aux/test_create_user_job.py
index 5c1e94dfd3..8f8ddcd65e 100644
--- a/tests/charts/airflow_aux/test_create_user_job.py
+++ b/tests/charts/airflow_aux/test_create_user_job.py
@@ -157,13 +157,13 @@ class TestCreateUserJob:
docs = render_chart(
values={
"createUserJob": {
- "extraVolumes": [{"name": "myvolume", "emptyDir": {}}],
+ "extraVolumes": [{"name": "myvolume-{{ .Chart.Name }}",
"emptyDir": {}}],
},
},
show_only=["templates/jobs/create-user-job.yaml"],
)
- assert {"name": "myvolume", "emptyDir": {}} == jmespath.search(
+ assert {"name": "myvolume-airflow", "emptyDir": {}} == jmespath.search(
"spec.template.spec.volumes[-1]", docs[0]
)
@@ -171,13 +171,13 @@ class TestCreateUserJob:
docs = render_chart(
values={
"createUserJob": {
- "extraVolumeMounts": [{"name": "foobar", "mountPath":
"foo/bar"}],
+ "extraVolumeMounts": [{"name": "foobar-{{ .Chart.Name }}",
"mountPath": "foo/bar"}],
},
},
show_only=["templates/jobs/create-user-job.yaml"],
)
- assert {"name": "foobar", "mountPath": "foo/bar"} == jmespath.search(
+ assert {"name": "foobar-airflow", "mountPath": "foo/bar"} ==
jmespath.search(
"spec.template.spec.containers[0].volumeMounts[-1]", docs[0]
)
diff --git a/tests/charts/airflow_aux/test_migrate_database_job.py
b/tests/charts/airflow_aux/test_migrate_database_job.py
index 45a1b378df..6b6936958d 100644
--- a/tests/charts/airflow_aux/test_migrate_database_job.py
+++ b/tests/charts/airflow_aux/test_migrate_database_job.py
@@ -195,13 +195,13 @@ class TestMigrateDatabaseJob:
docs = render_chart(
values={
"migrateDatabaseJob": {
- "extraVolumes": [{"name": "myvolume", "emptyDir": {}}],
+ "extraVolumes": [{"name": "myvolume-{{ .Chart.Name }}",
"emptyDir": {}}],
},
},
show_only=["templates/jobs/migrate-database-job.yaml"],
)
- assert {"name": "myvolume", "emptyDir": {}} == jmespath.search(
+ assert {"name": "myvolume-airflow", "emptyDir": {}} == jmespath.search(
"spec.template.spec.volumes[-1]", docs[0]
)
@@ -209,13 +209,13 @@ class TestMigrateDatabaseJob:
docs = render_chart(
values={
"migrateDatabaseJob": {
- "extraVolumeMounts": [{"name": "foobar", "mountPath":
"foo/bar"}],
+ "extraVolumeMounts": [{"name": "foobar-{{ .Chart.Name }}",
"mountPath": "foo/bar"}],
},
},
show_only=["templates/jobs/migrate-database-job.yaml"],
)
- assert {"name": "foobar", "mountPath": "foo/bar"} == jmespath.search(
+ assert {"name": "foobar-airflow", "mountPath": "foo/bar"} ==
jmespath.search(
"spec.template.spec.containers[0].volumeMounts[-1]", docs[0]
)
diff --git a/tests/charts/airflow_aux/test_pod_template_file.py
b/tests/charts/airflow_aux/test_pod_template_file.py
index 201d857a41..a14c713107 100644
--- a/tests/charts/airflow_aux/test_pod_template_file.py
+++ b/tests/charts/airflow_aux/test_pod_template_file.py
@@ -521,19 +521,21 @@ class TestPodTemplateFile:
docs = render_chart(
values={
"workers": {
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "test-volume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "test-volume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [
+ {"name": "test-volume-{{ .Chart.Name }}", "mountPath":
"/opt/test"}
+ ],
}
},
show_only=["templates/pod-template-file.yaml"],
chart_dir=self.temp_chart_dir,
)
- assert "test-volume" in jmespath.search(
+ assert "test-volume-airflow" in jmespath.search(
"spec.volumes[*].name",
docs[0],
)
- assert "test-volume" in jmespath.search(
+ assert "test-volume-airflow" in jmespath.search(
"spec.containers[0].volumeMounts[*].name",
docs[0],
)
diff --git a/tests/charts/airflow_core/test_dag_processor.py
b/tests/charts/airflow_core/test_dag_processor.py
index bbc811e447..37bba48cc5 100644
--- a/tests/charts/airflow_core/test_dag_processor.py
+++ b/tests/charts/airflow_core/test_dag_processor.py
@@ -110,18 +110,20 @@ class TestDagProcessor:
values={
"dagProcessor": {
"enabled": True,
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "test-volume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "test-volume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [
+ {"name": "test-volume-{{ .Chart.Name }}", "mountPath":
"/opt/test"}
+ ],
},
},
show_only=["templates/dag-processor/dag-processor-deployment.yaml"],
)
- assert "test-volume" ==
jmespath.search("spec.template.spec.volumes[1].name", docs[0])
- assert "test-volume" == jmespath.search(
+ assert "test-volume-airflow" ==
jmespath.search("spec.template.spec.volumes[1].name", docs[0])
+ assert "test-volume-airflow" == jmespath.search(
"spec.template.spec.containers[0].volumeMounts[0].name", docs[0]
)
- assert "test-volume" == jmespath.search(
+ assert "test-volume-airflow" == jmespath.search(
"spec.template.spec.initContainers[0].volumeMounts[0].name",
docs[0]
)
diff --git a/tests/charts/airflow_core/test_scheduler.py
b/tests/charts/airflow_core/test_scheduler.py
index 82388f4740..32a8aa2921 100644
--- a/tests/charts/airflow_core/test_scheduler.py
+++ b/tests/charts/airflow_core/test_scheduler.py
@@ -106,17 +106,22 @@ class TestScheduler:
values={
"executor": "CeleryExecutor",
"scheduler": {
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "test-volume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "test-volume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [
+ {"name": "test-volume-{{ .Chart.Name }}", "mountPath":
"/opt/test"}
+ ],
},
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)
- assert "test-volume" in
jmespath.search("spec.template.spec.volumes[*].name", docs[0])
- assert "test-volume" in jmespath.search(
+ assert "test-volume-airflow" in
jmespath.search("spec.template.spec.volumes[*].name", docs[0])
+ assert "test-volume-airflow" in jmespath.search(
"spec.template.spec.containers[0].volumeMounts[*].name", docs[0]
)
+ assert "test-volume-airflow" == jmespath.search(
+ "spec.template.spec.initContainers[0].volumeMounts[-1].name",
docs[0]
+ )
def test_should_add_global_volume_and_global_volume_mount(self):
docs = render_chart(
diff --git a/tests/charts/airflow_core/test_triggerer.py
b/tests/charts/airflow_core/test_triggerer.py
index b4589877e0..c91721fbea 100644
--- a/tests/charts/airflow_core/test_triggerer.py
+++ b/tests/charts/airflow_core/test_triggerer.py
@@ -125,17 +125,22 @@ class TestTriggerer:
docs = render_chart(
values={
"triggerer": {
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "test-volume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "test-volume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [
+ {"name": "test-volume-{{ .Chart.Name }}", "mountPath":
"/opt/test"}
+ ],
},
},
show_only=["templates/triggerer/triggerer-deployment.yaml"],
)
- assert "test-volume" ==
jmespath.search("spec.template.spec.volumes[1].name", docs[0])
- assert "test-volume" == jmespath.search(
+ assert "test-volume-airflow" ==
jmespath.search("spec.template.spec.volumes[1].name", docs[0])
+ assert "test-volume-airflow" == jmespath.search(
"spec.template.spec.containers[0].volumeMounts[0].name", docs[0]
)
+ assert "test-volume-airflow" == jmespath.search(
+ "spec.template.spec.initContainers[0].volumeMounts[-1].name",
docs[0]
+ )
def test_should_add_global_volume_and_global_volume_mount(self):
docs = render_chart(
diff --git a/tests/charts/airflow_core/test_worker.py
b/tests/charts/airflow_core/test_worker.py
index 23075f45f6..a49b78fee4 100644
--- a/tests/charts/airflow_core/test_worker.py
+++ b/tests/charts/airflow_core/test_worker.py
@@ -118,17 +118,22 @@ class TestWorker:
values={
"executor": "CeleryExecutor",
"workers": {
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "test-volume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "test-volume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [
+ {"name": "test-volume-{{ .Chart.Name }}", "mountPath":
"/opt/test"}
+ ],
},
},
show_only=["templates/workers/worker-deployment.yaml"],
)
- assert "test-volume" ==
jmespath.search("spec.template.spec.volumes[0].name", docs[0])
- assert "test-volume" == jmespath.search(
+ assert "test-volume-airflow" ==
jmespath.search("spec.template.spec.volumes[0].name", docs[0])
+ assert "test-volume-airflow" == jmespath.search(
"spec.template.spec.containers[0].volumeMounts[0].name", docs[0]
)
+ assert "test-volume-airflow" == jmespath.search(
+ "spec.template.spec.initContainers[0].volumeMounts[-1].name",
docs[0]
+ )
def test_should_add_global_volume_and_global_volume_mount(self):
docs = render_chart(
diff --git a/tests/charts/other/test_flower.py
b/tests/charts/other/test_flower.py
index 45a2ff4ef1..779e3a4955 100644
--- a/tests/charts/other/test_flower.py
+++ b/tests/charts/other/test_flower.py
@@ -256,15 +256,17 @@ class TestFlowerDeployment:
values={
"flower": {
"enabled": True,
- "extraVolumes": [{"name": "myvolume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "myvolume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "myvolume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [{"name": "myvolume-{{ .Chart.Name
}}", "mountPath": "/opt/test"}],
},
},
show_only=["templates/flower/flower-deployment.yaml"],
)
- assert {"name": "myvolume", "emptyDir": {}} in
jmespath.search("spec.template.spec.volumes", docs[0])
- assert {"name": "myvolume", "mountPath": "/opt/test"} in
jmespath.search(
+ assert {"name": "myvolume-airflow", "emptyDir": {}} in jmespath.search(
+ "spec.template.spec.volumes", docs[0]
+ )
+ assert {"name": "myvolume-airflow", "mountPath": "/opt/test"} in
jmespath.search(
"spec.template.spec.containers[0].volumeMounts", docs[0]
)
diff --git a/tests/charts/other/test_git_sync_scheduler.py
b/tests/charts/other/test_git_sync_scheduler.py
index e47d00686c..597458ae98 100644
--- a/tests/charts/other/test_git_sync_scheduler.py
+++ b/tests/charts/other/test_git_sync_scheduler.py
@@ -186,8 +186,10 @@ class TestGitSyncSchedulerTest:
values={
"executor": "CeleryExecutor",
"scheduler": {
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "test-volume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "test-volume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [
+ {"name": "test-volume-{{ .Chart.Name }}", "mountPath":
"/opt/test"}
+ ],
},
"dags": {
"gitSync": {
@@ -198,10 +200,10 @@ class TestGitSyncSchedulerTest:
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)
- assert {"name": "test-volume", "emptyDir": {}} in jmespath.search(
+ assert {"name": "test-volume-airflow", "emptyDir": {}} in
jmespath.search(
"spec.template.spec.volumes", docs[0]
)
- assert {"name": "test-volume", "mountPath": "/opt/test"} in
jmespath.search(
+ assert {"name": "test-volume-airflow", "mountPath": "/opt/test"} in
jmespath.search(
"spec.template.spec.containers[0].volumeMounts", docs[0]
)
@@ -210,25 +212,27 @@ class TestGitSyncSchedulerTest:
values={
"executor": "CeleryExecutor",
"scheduler": {
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
+ "extraVolumes": [{"name": "test-volume-{{ .Values.executor
}}", "emptyDir": {}}],
},
"dags": {
"gitSync": {
"enabled": True,
- "extraVolumeMounts": [{"mountPath": "/opt/test",
"name": "test-volume"}],
+ "extraVolumeMounts": [
+ {"mountPath": "/opt/test", "name": "test-volume-{{
.Values.executor }}"}
+ ],
}
},
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)
- assert {"name": "test-volume", "emptyDir": {}} in jmespath.search(
+ assert {"name": "test-volume-CeleryExecutor", "emptyDir": {}} in
jmespath.search(
"spec.template.spec.volumes", docs[0]
)
assert {"mountPath": "/git", "name": "dags"} in jmespath.search(
"spec.template.spec.containers[1].volumeMounts", docs[0]
)
- assert {"name": "test-volume", "mountPath": "/opt/test"} in
jmespath.search(
+ assert {"name": "test-volume-CeleryExecutor", "mountPath":
"/opt/test"} in jmespath.search(
"spec.template.spec.containers[1].volumeMounts", docs[0]
)
diff --git a/tests/charts/other/test_pgbouncer.py
b/tests/charts/other/test_pgbouncer.py
index 901ea71d48..4445539ea2 100644
--- a/tests/charts/other/test_pgbouncer.py
+++ b/tests/charts/other/test_pgbouncer.py
@@ -288,22 +288,25 @@ class TestPgbouncer:
"enabled": True,
"extraVolumes": [
{
- "name": "pgbouncer-client-certificates",
+ "name": "pgbouncer-client-certificates-{{
.Chart.Name }}",
"secret": {"secretName":
"pgbouncer-client-tls-certificate"},
}
],
"extraVolumeMounts": [
- {"name": "pgbouncer-client-certificates", "mountPath":
"/etc/pgbouncer/certs"}
+ {
+ "name": "pgbouncer-client-certificates-{{
.Chart.Name }}",
+ "mountPath": "/etc/pgbouncer/certs",
+ }
],
},
},
show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"],
)
- assert "pgbouncer-client-certificates" in jmespath.search(
+ assert "pgbouncer-client-certificates-airflow" in jmespath.search(
"spec.template.spec.volumes[*].name", docs[0]
)
- assert "pgbouncer-client-certificates" in jmespath.search(
+ assert "pgbouncer-client-certificates-airflow" in jmespath.search(
"spec.template.spec.containers[0].volumeMounts[*].name", docs[0]
)
diff --git a/tests/charts/webserver/test_webserver.py
b/tests/charts/webserver/test_webserver.py
index 6b5e590630..4b1e7ec375 100644
--- a/tests/charts/webserver/test_webserver.py
+++ b/tests/charts/webserver/test_webserver.py
@@ -184,17 +184,22 @@ class TestWebserverDeployment:
docs = render_chart(
values={
"webserver": {
- "extraVolumes": [{"name": "test-volume", "emptyDir": {}}],
- "extraVolumeMounts": [{"name": "test-volume", "mountPath":
"/opt/test"}],
+ "extraVolumes": [{"name": "test-volume-{{ .Chart.Name }}",
"emptyDir": {}}],
+ "extraVolumeMounts": [
+ {"name": "test-volume-{{ .Chart.Name }}", "mountPath":
"/opt/test"}
+ ],
},
},
show_only=["templates/webserver/webserver-deployment.yaml"],
)
- assert "test-volume" ==
jmespath.search("spec.template.spec.volumes[-1].name", docs[0])
- assert "test-volume" == jmespath.search(
+ assert "test-volume-airflow" ==
jmespath.search("spec.template.spec.volumes[-1].name", docs[0])
+ assert "test-volume-airflow" == jmespath.search(
"spec.template.spec.containers[0].volumeMounts[-1].name", docs[0]
)
+ assert "test-volume-airflow" == jmespath.search(
+ "spec.template.spec.initContainers[0].volumeMounts[-1].name",
docs[0]
+ )
def test_should_add_global_volume_and_global_volume_mount(self):
docs = render_chart(