Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add templating for PVC storageClassName #35581

Merged
merged 14 commits into from
Nov 12, 2023
2 changes: 1 addition & 1 deletion chart/templates/dags-persistent-volume-claim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
{{- if (eq "-" .Values.dags.persistence.storageClassName) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.dags.persistence.storageClassName }}"
storageClassName: {{ tpl .Values.dags.persistence.storageClassName . | quote }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion chart/templates/logs-persistent-volume-claim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
{{- if (eq "-" .Values.logs.persistence.storageClassName) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.logs.persistence.storageClassName }}"
storageClassName: {{ tpl .Values.logs.persistence.storageClassName . | quote }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion chart/templates/redis/redis-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ spec:
{{- end }}
spec:
{{- if .Values.redis.persistence.storageClassName }}
storageClassName: {{ .Values.redis.persistence.storageClassName }}
storageClassName: {{ tpl .Values.redis.persistence.storageClassName . | quote }}
{{- end }}
accessModes: ["ReadWriteOnce"]
resources:
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ spec:
{{- end }}
spec:
{{- if .Values.workers.persistence.storageClassName }}
storageClassName: {{ .Values.workers.persistence.storageClassName }}
storageClassName: {{ tpl .Values.workers.persistence.storageClassName . | quote }}
{{- end }}
accessModes: ["ReadWriteOnce"]
resources:
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/triggerer/triggerer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ spec:
{{- end }}
spec:
{{- if .Values.triggerer.persistence.storageClassName }}
storageClassName: {{ .Values.triggerer.persistence.storageClassName }}
storageClassName: {{ tpl .Values.triggerer.persistence.storageClassName . | quote }}
{{- end }}
accessModes: ["ReadWriteOnce"]
resources:
Expand Down
2 changes: 1 addition & 1 deletion chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ spec:
{{- end }}
spec:
{{- if .Values.workers.persistence.storageClassName }}
storageClassName: {{ .Values.workers.persistence.storageClassName }}
storageClassName: {{ tpl .Values.workers.persistence.storageClassName . | quote }}
{{- end }}
accessModes: ["ReadWriteOnce"]
resources:
Expand Down
15 changes: 15 additions & 0 deletions helm_tests/airflow_aux/test_logs_persistent_volume_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,18 @@ def test_should_set_pvc_details_correctly(self):
"resources": {"requests": {"storage": "1G"}},
"storageClassName": "MyStorageClass",
} == jmespath.search("spec", docs[0])

def test_logs_persistent_volume_claim_template_storage_class_name(self):
docs = render_chart(
values={
"logs": {
"persistence": {
"existingClaim": None,
"enabled": True,
"storageClassName": "{{ .Release.Name }}-storage-class",
}
}
},
show_only=["templates/logs-persistent-volume-claim.yaml"],
)
assert "release-name-storage-class" == jmespath.search("spec.storageClassName", docs[0])
18 changes: 18 additions & 0 deletions helm_tests/airflow_core/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,24 @@ def test_scheduler_pod_hostaliases(self):
assert "127.0.0.1" == jmespath.search("spec.template.spec.hostAliases[0].ip", docs[0])
assert "foo.local" == jmespath.search("spec.template.spec.hostAliases[0].hostnames[0]", docs[0])

def test_scheduler_template_storage_class_name(self):
docs = render_chart(
values={
"workers": {
"persistence": {
"storageClassName": "{{ .Release.Name }}-storage-class",
"enabled": True,
}
},
"logs": {"persistence": {"enabled": False}},
"executor": "LocalExecutor",
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)
assert "release-name-storage-class" == jmespath.search(
"spec.volumeClaimTemplates[0].spec.storageClassName", docs[0]
)


class TestSchedulerNetworkPolicy:
"""Tests scheduler network policy."""
Expand Down
9 changes: 9 additions & 0 deletions helm_tests/airflow_core/test_triggerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,15 @@ def test_should_add_component_specific_annotations(self):
assert "annotations" in jmespath.search("metadata", docs[0])
assert jmespath.search("metadata.annotations", docs[0])["test_annotation"] == "test_annotation_value"

def test_triggerer_template_storage_class_name(self):
docs = render_chart(
values={"triggerer": {"persistence": {"storageClassName": "{{ .Release.Name }}-storage-class"}}},
show_only=["templates/triggerer/triggerer-deployment.yaml"],
)
assert "release-name-storage-class" == jmespath.search(
"spec.volumeClaimTemplates[0].spec.storageClassName", docs[0]
)


class TestTriggererServiceAccount:
"""Tests triggerer service account."""
Expand Down
9 changes: 9 additions & 0 deletions helm_tests/airflow_core/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,15 @@ def test_podannotations_precedence(self, globalScope, localScope, precedence):
else:
assert jmespath.search("spec.template.metadata.annotations.scope", docs[0]) is None

def test_worker_template_storage_class_name(self):
docs = render_chart(
values={"workers": {"persistence": {"storageClassName": "{{ .Release.Name }}-storage-class"}}},
show_only=["templates/workers/worker-deployment.yaml"],
)
assert "release-name-storage-class" == jmespath.search(
"spec.volumeClaimTemplates[0].spec.storageClassName", docs[0]
)


class TestWorkerLogGroomer(LogGroomerTestBase):
"""Worker groomer."""
Expand Down
15 changes: 15 additions & 0 deletions helm_tests/other/test_dags_persistent_volume_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ def test_multiple_annotations(self):
annotations = jmespath.search("metadata.annotations", docs[0])
assert "value" == annotations.get("key")
assert "value-two" == annotations.get("key-two")

def test_dags_persistent_volume_claim_template_storage_class_name(self):
docs = render_chart(
values={
"dags": {
"persistence": {
"existingClaim": None,
"enabled": True,
"storageClassName": "{{ .Release.Name }}-storage-class",
}
}
},
show_only=["templates/dags-persistent-volume-claim.yaml"],
)
assert "release-name-storage-class" == jmespath.search("spec.storageClassName", docs[0])
9 changes: 9 additions & 0 deletions helm_tests/other/test_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ def test_priority_class_name(self):
docs[0],
)

def test_redis_template_storage_class_name(self):
docs = render_chart(
values={"redis": {"persistence": {"storageClassName": "{{ .Release.Name }}-storage-class"}}},
show_only=["templates/redis/redis-statefulset.yaml"],
)
assert "release-name-storage-class" == jmespath.search(
"spec.volumeClaimTemplates[0].spec.storageClassName", docs[0]
)


class TestRedisServiceAccount:
"""Tests redis service account."""
Expand Down