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
3 changes: 3 additions & 0 deletions chart/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ server_tls_key_file = /etc/pgbouncer/server.key
{{ define "airflow_dags_mount" -}}
- name: dags
mountPath: {{ (printf "%s/dags" .Values.airflowHome) }}
{{ if .Values.dags.persistence.subPath -}}
subPath: {{ .Values.dags.persistence.subPath }}
{{- end }}
readOnly: {{ .Values.dags.gitSync.enabled | ternary "True" "False" }}
{{- end -}}

Expand Down
8 changes: 8 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4142,6 +4142,14 @@
"null"
],
"default": null
},
"subPath": {
"description": "Subpath within the PVC where dags are located.",
"type": [
"string",
"null"
],
"default": null
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,8 @@ dags:
accessMode: ReadWriteOnce
## the name of an existing PVC to use
existingClaim:
## optional subpath for dag volume mount
subPath: ~
gitSync:
enabled: false

Expand Down
40 changes: 31 additions & 9 deletions tests/charts/test_airflow_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,45 @@ class TestAirflowCommon:

@parameterized.expand(
[
({"gitSync": {"enabled": True}}, True),
({"persistence": {"enabled": True}}, False),
(
{"gitSync": {"enabled": True}},
{
"mountPath": "/opt/airflow/dags",
"name": "dags",
"readOnly": True,
},
),
(
{"persistence": {"enabled": True}},
{
"mountPath": "/opt/airflow/dags",
"name": "dags",
"readOnly": False,
},
),
(
{
"gitSync": {"enabled": True},
"persistence": {"enabled": True},
},
True,
{
"mountPath": "/opt/airflow/dags",
"name": "dags",
"readOnly": True,
},
),
(
{"persistence": {"enabled": True, "subPath": "test/dags"}},
{
"subPath": "test/dags",
"mountPath": "/opt/airflow/dags",
"name": "dags",
"readOnly": False,
},
),
]
)
def test_dags_mount(self, dag_values, expected_read_only):
def test_dags_mount(self, dag_values, expected_mount):
docs = render_chart(
values={
"dags": dag_values,
Expand All @@ -59,11 +86,6 @@ def test_dags_mount(self, dag_values, expected_read_only):

assert 3 == len(docs)
for doc in docs:
expected_mount = {
"mountPath": "/opt/airflow/dags",
"name": "dags",
"readOnly": expected_read_only,
}
assert expected_mount in jmespath.search("spec.template.spec.containers[0].volumeMounts", doc)

def test_annotations(self):
Expand Down