This is an automated email from the ASF dual-hosted git repository. jedcunningham 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 743121b enable optional subPath for dags volume mount (#22323) 743121b is described below commit 743121b09ee0db672dc1376e5f644f20b9f5b8d8 Author: Adam Boscarino <aboscar...@devoted.com> AuthorDate: Mon Mar 28 16:40:04 2022 -0400 enable optional subPath for dags volume mount (#22323) --- chart/templates/_helpers.yaml | 3 +++ chart/values.schema.json | 8 ++++++++ chart/values.yaml | 2 ++ tests/charts/test_airflow_common.py | 40 ++++++++++++++++++++++++++++--------- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/chart/templates/_helpers.yaml b/chart/templates/_helpers.yaml index 5f9acd9..b5d7e80 100644 --- a/chart/templates/_helpers.yaml +++ b/chart/templates/_helpers.yaml @@ -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 -}} diff --git a/chart/values.schema.json b/chart/values.schema.json index 2f1c58e..0e98a99 100644 --- a/chart/values.schema.json +++ b/chart/values.schema.json @@ -4201,6 +4201,14 @@ "null" ], "default": null + }, + "subPath": { + "description": "Subpath within the PVC where dags are located.", + "type": [ + "string", + "null" + ], + "default": null } } }, diff --git a/chart/values.yaml b/chart/values.yaml index ffbd72b..36ea75e 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -1531,6 +1531,8 @@ dags: accessMode: ReadWriteOnce ## the name of an existing PVC to use existingClaim: + ## optional subpath for dag volume mount + subPath: ~ gitSync: enabled: false diff --git a/tests/charts/test_airflow_common.py b/tests/charts/test_airflow_common.py index c818365..4609168 100644 --- a/tests/charts/test_airflow_common.py +++ b/tests/charts/test_airflow_common.py @@ -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, @@ -59,11 +86,6 @@ class TestAirflowCommon: 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):