diff --git a/chart/files/pod-template-file.kubernetes-helm-yaml b/chart/files/pod-template-file.kubernetes-helm-yaml index dac3ae1c4ead0..80a907e7521b6 100644 --- a/chart/files/pod-template-file.kubernetes-helm-yaml +++ b/chart/files/pod-template-file.kubernetes-helm-yaml @@ -67,16 +67,7 @@ spec: volumeMounts: - mountPath: {{ template "airflow_logs" . }} name: logs - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true -{{- if .Values.airflowLocalSettings }} - - name: config - mountPath: {{ template "airflow_local_setting_path" . }} - subPath: airflow_local_settings.py - readOnly: true -{{- end }} +{{- include "airflow_config_mount" . | nindent 8 }} {{- if or .Values.dags.gitSync.enabled .Values.dags.persistence.enabled }} {{- include "airflow_dags_mount" . | nindent 8 }} {{- end }} diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml index 1ff7a64cae347..f3cafc03731b0 100644 --- a/chart/templates/_helpers.yaml +++ b/chart/templates/_helpers.yaml @@ -451,6 +451,19 @@ server_tls_key_file = /etc/pgbouncer/server.key {{ (printf "%s-airflow-config" .Release.Name) }} {{- end }} +{{ define "airflow_config_mount" -}} +- name: config + mountPath: {{ template "airflow_config_path" . }} + subPath: airflow.cfg + readOnly: true + {{- if .Values.airflowLocalSettings }} +- name: config + mountPath: {{ template "airflow_local_setting_path" . }} + subPath: airflow_local_settings.py + readOnly: true + {{- end }} +{{- end -}} + {{/* Create the name of the webserver service account to use */}} diff --git a/chart/templates/cleanup/cleanup-cronjob.yaml b/chart/templates/cleanup/cleanup-cronjob.yaml index eb83fe04b22cf..fa93a73075e0c 100644 --- a/chart/templates/cleanup/cleanup-cronjob.yaml +++ b/chart/templates/cleanup/cleanup-cronjob.yaml @@ -101,10 +101,7 @@ spec: {{- include "standard_airflow_environment" . | indent 12 }} {{- include "container_extra_envs" (list . .Values.cleanup.env) | indent 12 }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 16 }} resources: {{ toYaml .Values.cleanup.resources | indent 16 }} volumes: diff --git a/chart/templates/dag-processor/dag-processor-deployment.yaml b/chart/templates/dag-processor/dag-processor-deployment.yaml index d4e6e1f7900e0..fef28af5aac27 100644 --- a/chart/templates/dag-processor/dag-processor-deployment.yaml +++ b/chart/templates/dag-processor/dag-processor-deployment.yaml @@ -116,10 +116,7 @@ spec: image: {{ template "airflow_image_for_migrations" . }} imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} args: {{- include "wait-for-migrations-command" . | nindent 10 }} envFrom: @@ -155,16 +152,7 @@ spec: {{- end }} - name: logs mountPath: {{ template "airflow_logs" . }} - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true - {{- if .Values.airflowLocalSettings }} - - name: config - mountPath: {{ template "airflow_local_setting_path" . }} - subPath: airflow_local_settings.py - readOnly: true - {{- end }} +{{- include "airflow_config_mount" . | nindent 12 }} {{- if or .Values.dags.persistence.enabled .Values.dags.gitSync.enabled }} {{- include "airflow_dags_mount" . | nindent 12 }} {{- end }} diff --git a/chart/templates/flower/flower-deployment.yaml b/chart/templates/flower/flower-deployment.yaml index f8c9b2a66361d..ca39b369d4f6a 100644 --- a/chart/templates/flower/flower-deployment.yaml +++ b/chart/templates/flower/flower-deployment.yaml @@ -96,10 +96,7 @@ spec: resources: {{ toYaml .Values.flower.resources | indent 12 }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.flower.extraVolumeMounts }} {{ toYaml .Values.flower.extraVolumeMounts | nindent 12 }} {{- end }} diff --git a/chart/templates/jobs/create-user-job.yaml b/chart/templates/jobs/create-user-job.yaml index 16029a9dda3b7..784ae05262de0 100644 --- a/chart/templates/jobs/create-user-job.yaml +++ b/chart/templates/jobs/create-user-job.yaml @@ -105,10 +105,7 @@ spec: resources: {{ toYaml .Values.createUserJob.resources | indent 12 }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.createUserJob.extraVolumeMounts }} {{ toYaml .Values.createUserJob.extraVolumeMounts | nindent 12 }} {{- end }} diff --git a/chart/templates/jobs/migrate-database-job.yaml b/chart/templates/jobs/migrate-database-job.yaml index 84e51880d4cfd..5669fe2d401fe 100644 --- a/chart/templates/jobs/migrate-database-job.yaml +++ b/chart/templates/jobs/migrate-database-job.yaml @@ -106,10 +106,7 @@ spec: resources: {{ toYaml .Values.migrateDatabaseJob.resources | indent 12 }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.migrateDatabaseJob.extraVolumeMounts }} {{ toYaml .Values.migrateDatabaseJob.extraVolumeMounts | nindent 12 }} {{- end }} diff --git a/chart/templates/scheduler/scheduler-deployment.yaml b/chart/templates/scheduler/scheduler-deployment.yaml index cc6563d8ad390..89e5ab3d8c98e 100644 --- a/chart/templates/scheduler/scheduler-deployment.yaml +++ b/chart/templates/scheduler/scheduler-deployment.yaml @@ -136,10 +136,7 @@ spec: image: {{ template "airflow_image_for_migrations" . }} imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.scheduler.extraVolumeMounts }} {{ toYaml .Values.scheduler.extraVolumeMounts | indent 12 }} {{- end }} @@ -206,16 +203,7 @@ spec: {{- end }} - name: logs mountPath: {{ template "airflow_logs" . }} - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true - {{- if .Values.airflowLocalSettings }} - - name: config - mountPath: {{ template "airflow_local_setting_path" . }} - subPath: airflow_local_settings.py - readOnly: true - {{- end }} +{{- include "airflow_config_mount" . | nindent 12 }} {{- if and $localOrDagProcessorDisabled (or .Values.dags.persistence.enabled .Values.dags.gitSync.enabled) }} {{- include "airflow_dags_mount" . | nindent 12 }} {{- end }} diff --git a/chart/templates/triggerer/triggerer-deployment.yaml b/chart/templates/triggerer/triggerer-deployment.yaml index b5ef86b82fcd3..d79bc5ccc4a94 100644 --- a/chart/templates/triggerer/triggerer-deployment.yaml +++ b/chart/templates/triggerer/triggerer-deployment.yaml @@ -116,10 +116,7 @@ spec: image: {{ template "airflow_image_for_migrations" . }} imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.triggerer.extraVolumeMounts }} {{ toYaml .Values.triggerer.extraVolumeMounts | nindent 12 }} {{- end }} @@ -158,16 +155,7 @@ spec: {{- end }} - name: logs mountPath: {{ template "airflow_logs" . }} - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true - {{- if .Values.airflowLocalSettings }} - - name: config - mountPath: {{ template "airflow_local_setting_path" . }} - subPath: airflow_local_settings.py - readOnly: true - {{- end }} +{{- include "airflow_config_mount" . | nindent 12 }} {{- if or .Values.dags.persistence.enabled .Values.dags.gitSync.enabled }} {{- include "airflow_dags_mount" . | nindent 12 }} {{- end }} diff --git a/chart/templates/webserver/webserver-deployment.yaml b/chart/templates/webserver/webserver-deployment.yaml index 386e10a3b7119..e745eed6a8a2a 100644 --- a/chart/templates/webserver/webserver-deployment.yaml +++ b/chart/templates/webserver/webserver-deployment.yaml @@ -128,10 +128,7 @@ spec: image: {{ template "airflow_image_for_migrations" . }} imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.webserver.extraVolumeMounts }} {{ toYaml .Values.webserver.extraVolumeMounts | indent 12 }} {{- end }} @@ -171,22 +168,13 @@ spec: subPath: pod_template_file.yaml readOnly: true {{- end }} - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.webserver.webserverConfig }} - name: webserver-config mountPath: {{ template "airflow_webserver_config_path" . }} subPath: webserver_config.py readOnly: true {{- end }} -{{- if .Values.airflowLocalSettings }} - - name: config - mountPath: {{ template "airflow_local_setting_path" . }} - subPath: airflow_local_settings.py - readOnly: true -{{- end }} {{- if and (semverCompare "<2.0.0" .Values.airflowVersion) (or .Values.dags.gitSync.enabled .Values.dags.persistence.enabled) }} {{- include "airflow_dags_mount" . | nindent 12 }} {{- end }} diff --git a/chart/templates/workers/worker-deployment.yaml b/chart/templates/workers/worker-deployment.yaml index b0ed1cfe95c42..c60b09ce3e418 100644 --- a/chart/templates/workers/worker-deployment.yaml +++ b/chart/templates/workers/worker-deployment.yaml @@ -146,10 +146,7 @@ spec: image: {{ template "airflow_image_for_migrations" . }} imagePullPolicy: {{ .Values.images.airflow.pullPolicy }} volumeMounts: - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.workers.extraVolumeMounts }} {{ toYaml .Values.workers.extraVolumeMounts | indent 12 }} {{- end }} @@ -206,10 +203,7 @@ spec: {{- end }} - name: logs mountPath: {{ template "airflow_logs" . }} - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} {{- if .Values.workers.kerberosSidecar.enabled }} - name: config mountPath: {{ .Values.kerberos.configPath | quote }} @@ -219,12 +213,6 @@ spec: mountPath: {{ .Values.kerberos.ccacheMountPath | quote }} readOnly: true {{- end }} - {{- if .Values.airflowLocalSettings }} - - name: config - mountPath: {{ template "airflow_local_setting_path" . }} - subPath: airflow_local_settings.py - readOnly: true - {{- end }} {{- if or .Values.dags.persistence.enabled .Values.dags.gitSync.enabled }} {{- include "airflow_dags_mount" . | nindent 12 }} {{- end }} @@ -280,20 +268,11 @@ spec: volumeMounts: - name: logs mountPath: {{ template "airflow_logs" . }} - - name: config - mountPath: {{ template "airflow_config_path" . }} - subPath: airflow.cfg - readOnly: true +{{- include "airflow_config_mount" . | nindent 12 }} - name: config mountPath: {{ .Values.kerberos.configPath | quote }} subPath: krb5.conf readOnly: true - {{- if .Values.airflowLocalSettings }} - - name: config - mountPath: {{ template "airflow_local_setting_path" . }} - subPath: airflow_local_settings.py - readOnly: true - {{- end }} - name: kerberos-keytab subPath: "kerberos.keytab" mountPath: {{ .Values.kerberos.keytabPath | quote }} diff --git a/tests/charts/test_cleanup_pods.py b/tests/charts/test_cleanup_pods.py index 720676f914f9b..f6b15a5f6b462 100644 --- a/tests/charts/test_cleanup_pods.py +++ b/tests/charts/test_cleanup_pods.py @@ -239,6 +239,34 @@ def test_should_set_job_history_limits(self): assert 2 == jmespath.search("spec.failedJobsHistoryLimit", docs[0]) assert 4 == jmespath.search("spec.successfulJobsHistoryLimit", docs[0]) + def test_no_airflow_local_settings(self): + docs = render_chart( + values={ + "cleanup": {"enabled": True}, + "airflowLocalSettings": None, + }, + show_only=["templates/cleanup/cleanup-cronjob.yaml"], + ) + volume_mounts = jmespath.search( + "spec.jobTemplate.spec.template.spec.containers[0].volumeMounts", docs[0] + ) + assert "airflow_local_settings.py" not in str(volume_mounts) + + def test_airflow_local_settings(self): + docs = render_chart( + values={ + "cleanup": {"enabled": True}, + "airflowLocalSettings": "# Well hello!", + }, + show_only=["templates/cleanup/cleanup-cronjob.yaml"], + ) + assert { + "name": "config", + "mountPath": "/opt/airflow/config/airflow_local_settings.py", + "subPath": "airflow_local_settings.py", + "readOnly": True, + } in jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].volumeMounts", docs[0]) + class TestCleanupServiceAccount: def test_should_add_component_specific_labels(self): diff --git a/tests/charts/test_create_user_job.py b/tests/charts/test_create_user_job.py index 7deebb58b3dc0..74c0fa9f44200 100644 --- a/tests/charts/test_create_user_job.py +++ b/tests/charts/test_create_user_job.py @@ -319,6 +319,25 @@ def test_default_user_overrides(self): "whereisjane?", ] == jmespath.search("spec.template.spec.containers[0].args", docs[0]) + def test_no_airflow_local_settings(self): + docs = render_chart( + values={"airflowLocalSettings": None}, show_only=["templates/jobs/create-user-job.yaml"] + ) + volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts) + + def test_airflow_local_settings(self): + docs = render_chart( + values={"airflowLocalSettings": "# Well hello!"}, + show_only=["templates/jobs/create-user-job.yaml"], + ) + assert { + "name": "config", + "mountPath": "/opt/airflow/config/airflow_local_settings.py", + "subPath": "airflow_local_settings.py", + "readOnly": True, + } in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + class TestCreateUserJobServiceAccount: def test_should_add_component_specific_labels(self): diff --git a/tests/charts/test_dag_processor.py b/tests/charts/test_dag_processor.py index 06967f814d216..1e84480cd54a0 100644 --- a/tests/charts/test_dag_processor.py +++ b/tests/charts/test_dag_processor.py @@ -497,3 +497,27 @@ def test_dags_gitsync_with_persistence_no_sidecar_or_init_container(self): assert "git-sync-init" not in [ c["name"] for c in jmespath.search("spec.template.spec.initContainers", docs[0]) ] + + def test_no_airflow_local_settings(self): + docs = render_chart( + values={"dagProcessor": {"enabled": True}, "airflowLocalSettings": None}, + show_only=["templates/dag-processor/dag-processor-deployment.yaml"], + ) + volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts) + volume_mounts_init = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts_init) + + def test_airflow_local_settings(self): + docs = render_chart( + values={"dagProcessor": {"enabled": True}, "airflowLocalSettings": "# Well hello!"}, + show_only=["templates/dag-processor/dag-processor-deployment.yaml"], + ) + volume_mount = { + "name": "config", + "mountPath": "/opt/airflow/config/airflow_local_settings.py", + "subPath": "airflow_local_settings.py", + "readOnly": True, + } + assert volume_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert volume_mount in jmespath.search("spec.template.spec.initContainers[0].volumeMounts", docs[0]) diff --git a/tests/charts/test_flower.py b/tests/charts/test_flower.py index 321e3e1614733..47e560a330b4d 100644 --- a/tests/charts/test_flower.py +++ b/tests/charts/test_flower.py @@ -297,6 +297,27 @@ def test_should_add_component_specific_labels(self): assert "test_label" in jmespath.search("spec.template.metadata.labels", docs[0]) assert jmespath.search("spec.template.metadata.labels", docs[0])["test_label"] == "test_label_value" + def test_no_airflow_local_settings(self): + docs = render_chart( + values={"flower": {"enabled": True}, "airflowLocalSettings": None}, + show_only=["templates/flower/flower-deployment.yaml"], + ) + volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts) + + def test_airflow_local_settings(self): + docs = render_chart( + values={"flower": {"enabled": True}, "airflowLocalSettings": "# Well hello!"}, + show_only=["templates/flower/flower-deployment.yaml"], + ) + volume_mount = { + "name": "config", + "mountPath": "/opt/airflow/config/airflow_local_settings.py", + "subPath": "airflow_local_settings.py", + "readOnly": True, + } + assert volume_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + class TestFlowerService: @pytest.mark.parametrize( diff --git a/tests/charts/test_migrate_database_job.py b/tests/charts/test_migrate_database_job.py index 69ecb858eaf6b..9155954f60551 100644 --- a/tests/charts/test_migrate_database_job.py +++ b/tests/charts/test_migrate_database_job.py @@ -262,3 +262,22 @@ def test_command_and_args_overrides_are_templated(self): assert ["release-name"] == jmespath.search("spec.template.spec.containers[0].command", docs[0]) assert ["Helm"] == jmespath.search("spec.template.spec.containers[0].args", docs[0]) + + def test_no_airflow_local_settings(self): + docs = render_chart( + values={"airflowLocalSettings": None}, show_only=["templates/jobs/migrate-database-job.yaml"] + ) + volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts) + + def test_airflow_local_settings(self): + docs = render_chart( + values={"airflowLocalSettings": "# Well hello!"}, + show_only=["templates/jobs/migrate-database-job.yaml"], + ) + assert { + "name": "config", + "mountPath": "/opt/airflow/config/airflow_local_settings.py", + "subPath": "airflow_local_settings.py", + "readOnly": True, + } in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) diff --git a/tests/charts/test_scheduler.py b/tests/charts/test_scheduler.py index 0f36f708d13d3..3c456b862c16b 100644 --- a/tests/charts/test_scheduler.py +++ b/tests/charts/test_scheduler.py @@ -394,18 +394,22 @@ def test_no_airflow_local_settings(self): ) volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) assert "airflow_local_settings.py" not in str(volume_mounts) + volume_mounts_init = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts_init) def test_airflow_local_settings(self): docs = render_chart( values={"airflowLocalSettings": "# Well hello!"}, show_only=["templates/scheduler/scheduler-deployment.yaml"], ) - assert { + volume_mount = { "name": "config", "mountPath": "/opt/airflow/config/airflow_local_settings.py", "subPath": "airflow_local_settings.py", "readOnly": True, - } in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + } + assert volume_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert volume_mount in jmespath.search("spec.template.spec.initContainers[0].volumeMounts", docs[0]) @pytest.mark.parametrize( "executor, persistence, update_strategy, expected_update_strategy", diff --git a/tests/charts/test_triggerer.py b/tests/charts/test_triggerer.py index 42cbddc951901..5921d4e4ecbf1 100644 --- a/tests/charts/test_triggerer.py +++ b/tests/charts/test_triggerer.py @@ -470,6 +470,29 @@ def test_dags_gitsync_with_persistence_no_sidecar_or_init_container(self): c["name"] for c in jmespath.search("spec.template.spec.initContainers", docs[0]) ] + def test_no_airflow_local_settings(self): + docs = render_chart( + values={"airflowLocalSettings": None}, show_only=["templates/triggerer/triggerer-deployment.yaml"] + ) + volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts) + volume_mounts_init = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts_init) + + def test_airflow_local_settings(self): + docs = render_chart( + values={"airflowLocalSettings": "# Well hello!"}, + show_only=["templates/triggerer/triggerer-deployment.yaml"], + ) + volume_mount = { + "name": "config", + "mountPath": "/opt/airflow/config/airflow_local_settings.py", + "subPath": "airflow_local_settings.py", + "readOnly": True, + } + assert volume_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert volume_mount in jmespath.search("spec.template.spec.initContainers[0].volumeMounts", docs[0]) + class TestTriggererServiceAccount: def test_should_add_component_specific_labels(self): diff --git a/tests/charts/test_webserver.py b/tests/charts/test_webserver.py index d5f70d3d462a7..dbe8a80dd96d2 100644 --- a/tests/charts/test_webserver.py +++ b/tests/charts/test_webserver.py @@ -519,18 +519,22 @@ def test_no_airflow_local_settings(self): ) volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) assert "airflow_local_settings.py" not in str(volume_mounts) + volume_mounts_init = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts_init) def test_airflow_local_settings(self): docs = render_chart( values={"airflowLocalSettings": "# Well hello!"}, show_only=["templates/webserver/webserver-deployment.yaml"], ) - assert { + volume_mount = { "name": "config", "mountPath": "/opt/airflow/config/airflow_local_settings.py", "subPath": "airflow_local_settings.py", "readOnly": True, - } in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + } + assert volume_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert volume_mount in jmespath.search("spec.template.spec.initContainers[0].volumeMounts", docs[0]) def test_default_command_and_args(self): docs = render_chart(show_only=["templates/webserver/webserver-deployment.yaml"]) diff --git a/tests/charts/test_worker.py b/tests/charts/test_worker.py index c7c9acc3fc406..18387270724e2 100644 --- a/tests/charts/test_worker.py +++ b/tests/charts/test_worker.py @@ -451,18 +451,22 @@ def test_no_airflow_local_settings(self): ) volume_mounts = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) assert "airflow_local_settings.py" not in str(volume_mounts) + volume_mounts_init = jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert "airflow_local_settings.py" not in str(volume_mounts_init) def test_airflow_local_settings(self): docs = render_chart( values={"airflowLocalSettings": "# Well hello!"}, show_only=["templates/workers/worker-deployment.yaml"], ) - assert { + volume_mount = { "name": "config", "mountPath": "/opt/airflow/config/airflow_local_settings.py", "subPath": "airflow_local_settings.py", "readOnly": True, - } in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + } + assert volume_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", docs[0]) + assert volume_mount in jmespath.search("spec.template.spec.initContainers[0].volumeMounts", docs[0]) def test_airflow_local_settings_kerberos_sidecar(self): docs = render_chart(