Skip to content

Commit

Permalink
Mount airflow.cfg to pod_template_file (apache#12311)
Browse files Browse the repository at this point in the history
* Mount airflow.cfg to pod_template_file

k8sexecutor workers were launching without an airflow.cfg,
this was preventing logs from being sent to distributed logging systems.

* consistent naming
  • Loading branch information
dimberman authored Nov 13, 2020
1 parent 32b59f8 commit ce06be4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
15 changes: 11 additions & 4 deletions chart/files/pod-template-file.kubernetes-helm-yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ spec:
volumeMounts:
- mountPath: {{ template "airflow_logs" . }}
name: airflow-logs
- name: config
mountPath: {{ template "airflow_config_path" . }}
subPath: airflow.cfg
readOnly: true
{{- if .Values.scheduler.airflowLocalSettings }}
- name: config
mountPath: {{ template "airflow_local_setting_path" . }}
subPath: airflow_local_settings.py
readOnly: true
{{- end }}
{{- if .Values.dags.gitSync.knownHosts }}
- mountPath: /etc/git-secret/known_hosts
name: {{ .Values.dags.gitSync.knownHosts }}
Expand Down Expand Up @@ -92,7 +102,4 @@ spec:
{{- end }}
- configMap:
name: {{ include "airflow_config" . }}
name: airflow-config
- configMap:
name: {{ include "airflow_config" . }}
name: airflow-local-settings
name: config
21 changes: 21 additions & 0 deletions chart/tests/test_pod_template_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,27 @@ def test_should_set_a_custom_image_in_pod_template(self):
self.assertEqual("dummy_image:latest", jmespath.search("spec.containers[0].image", docs[0]))
self.assertEqual("base", jmespath.search("spec.containers[0].name", docs[0]))

def test_mount_airflow_cfg(self):
docs = render_chart(
values={},
show_only=["templates/pod-template-file.yaml"],
)

self.assertRegex(docs[0]["kind"], "Pod")
self.assertDictEqual(
{'configMap': {'name': 'RELEASE-NAME-airflow-config'}, 'name': 'airflow-config'},
jmespath.search("spec.volumes[1]", docs[0]),
)
self.assertDictEqual(
{
'name': 'config',
'mountPath': '/opt/airflow/airflow.cfg',
'subPath': 'airflow.cfg',
'readOnly': True,
},
jmespath.search("spec.containers[0].volumeMounts[1]", docs[0]),
)

def test_should_create_valid_affinity_and_node_selector(self):
docs = render_chart(
values={
Expand Down

0 comments on commit ce06be4

Please sign in to comment.