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
11 changes: 1 addition & 10 deletions chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
13 changes: 13 additions & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down
5 changes: 1 addition & 4 deletions chart/templates/cleanup/cleanup-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 2 additions & 14 deletions chart/templates/dag-processor/dag-processor-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand Down
5 changes: 1 addition & 4 deletions chart/templates/flower/flower-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
5 changes: 1 addition & 4 deletions chart/templates/jobs/create-user-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
5 changes: 1 addition & 4 deletions chart/templates/jobs/migrate-database-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
16 changes: 2 additions & 14 deletions chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
16 changes: 2 additions & 14 deletions chart/templates/triggerer/triggerer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
16 changes: 2 additions & 14 deletions chart/templates/webserver/webserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
27 changes: 3 additions & 24 deletions chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
28 changes: 28 additions & 0 deletions tests/charts/test_cleanup_pods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 19 additions & 0 deletions tests/charts/test_create_user_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
24 changes: 24 additions & 0 deletions tests/charts/test_dag_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
21 changes: 21 additions & 0 deletions tests/charts/test_flower.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading