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/scheduler/scheduler-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ spec:
{{- if and $stateful .Values.scheduler.updateStrategy }}
updateStrategy: {{- toYaml .Values.scheduler.updateStrategy | nindent 4 }}
{{- end }}
{{- if and $stateful .Values.workers.persistence.persistentVolumeClaimRetentionPolicy }}
persistentVolumeClaimRetentionPolicy: {{- toYaml .Values.workers.persistence.persistentVolumeClaimRetentionPolicy | nindent 4 }}
{{- end }}
{{- if and (not $stateful) .Values.scheduler.strategy }}
strategy: {{- toYaml .Values.scheduler.strategy | nindent 4 }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/triggerer/triggerer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ spec:
{{- if and (not $persistence) (.Values.triggerer.strategy) }}
strategy: {{- toYaml .Values.triggerer.strategy | nindent 4 }}
{{- end }}
{{- if and $persistence .Values.triggerer.persistence.persistentVolumeClaimRetentionPolicy }}
persistentVolumeClaimRetentionPolicy: {{- toYaml .Values.triggerer.persistence.persistentVolumeClaimRetentionPolicy | nindent 4 }}
{{- end }}
template:
metadata:
labels:
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/workers/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ spec:
{{- if $revisionHistoryLimit }}
revisionHistoryLimit: {{ $revisionHistoryLimit }}
{{- end }}
{{- if and $persistence .Values.workers.persistence.persistentVolumeClaimRetentionPolicy }}
persistentVolumeClaimRetentionPolicy: {{- toYaml .Values.workers.persistence.persistentVolumeClaimRetentionPolicy | nindent 4 }}
{{- end }}
selector:
matchLabels:
tier: airflow
Expand Down
29 changes: 29 additions & 0 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,10 @@
"type": "boolean",
"default": true
},
"persistentVolumeClaimRetentionPolicy": {
"$ref": "#/definitions/persistentVolumeClaimRetentionPolicy",
"description": "PersistentVolumeClaim retention policy to be used in the lifecycle of a StatefulSet"
},
"size": {
"description": "Volume size for worker StatefulSet.",
"type": "string",
Expand Down Expand Up @@ -2946,6 +2950,10 @@
"type": "string",
"default": "100Gi"
},
"persistentVolumeClaimRetentionPolicy": {
"$ref": "#/definitions/persistentVolumeClaimRetentionPolicy",
"description": "PersistentVolumeClaim retention policy to be used in the lifecycle of a StatefulSet"
},
"storageClassName": {
"description": "If using a custom StorageClass, pass name ref to all StatefulSets here.",
"type": [
Expand Down Expand Up @@ -11835,6 +11843,27 @@
}
}
}
},
"persistentVolumeClaimRetentionPolicy": {
"description": "PersistentVolumeClaim retention policy to be used in the lifecycle of a StatefulSet",
"type": [
"object",
"null"
],
"default": null,
"additionalProperties": false,
"properties": {
"whenDeleted": {
"description": "Whether to retain the PVC when the StatefulSet is deleted.",
"type": "string",
"default": "Retain"
},
"whenScaled": {
"description": "Whether to retain the PVC when the StatefulSet is scaled.",
"type": "string",
"default": "Retain"
}
}
}
}
}
7 changes: 7 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,11 @@ workers:
persistence:
# Enable persistent volumes
enabled: true
# This policy determines whether PVCs should be deleted when StatefulSet is scaled down or removed.
persistentVolumeClaimRetentionPolicy: ~
# persistentVolumeClaimRetentionPolicy:
# whenDeleted: Delete
# whenScaled: Delete
# Volume size for worker StatefulSet
size: 100Gi
# If using a custom storageClass, pass name ref to all statefulSets here
Expand Down Expand Up @@ -1532,6 +1537,8 @@ triggerer:
persistence:
# Enable persistent volumes
enabled: true
# This policy determines whether PVCs should be deleted when StatefulSet is scaled down or removed.
persistentVolumeClaimRetentionPolicy: ~
# Volume size for triggerer StatefulSet
size: 100Gi
# If using a custom storageClass, pass name ref to all statefulSets here
Expand Down
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 @@ -839,6 +839,24 @@ def test_scheduler_template_storage_class_name(self):
"spec.volumeClaimTemplates[0].spec.storageClassName", docs[0]
)

def test_persistent_volume_claim_retention_policy(self):
docs = render_chart(
values={
"executor": "LocalExecutor",
"workers": {
"persistence": {
"enabled": True,
"persistentVolumeClaimRetentionPolicy": {"whenDeleted": "Delete"},
}
},
},
show_only=["templates/scheduler/scheduler-deployment.yaml"],
)

assert {
"whenDeleted": "Delete",
} == jmespath.search("spec.persistentVolumeClaimRetentionPolicy", docs[0])


class TestSchedulerNetworkPolicy:
"""Tests scheduler network policy."""
Expand Down
18 changes: 18 additions & 0 deletions helm_tests/airflow_core/test_triggerer.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,24 @@ def test_triggerer_template_storage_class_name(self):
"spec.volumeClaimTemplates[0].spec.storageClassName", docs[0]
)

def test_persistent_volume_claim_retention_policy(self):
docs = render_chart(
values={
"executor": "CeleryExecutor",
"triggerer": {
"persistence": {
"enabled": True,
"persistentVolumeClaimRetentionPolicy": {"whenDeleted": "Delete"},
}
},
},
show_only=["templates/triggerer/triggerer-deployment.yaml"],
)

assert {
"whenDeleted": "Delete",
} == jmespath.search("spec.persistentVolumeClaimRetentionPolicy", docs[0])


class TestTriggererServiceAccount:
"""Tests triggerer service account."""
Expand Down
18 changes: 18 additions & 0 deletions helm_tests/airflow_core/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,24 @@ def test_should_add_extra_containers(self):
"image": "test-registry/test-repo:test-tag",
} == jmespath.search("spec.template.spec.containers[-1]", docs[0])

def test_persistent_volume_claim_retention_policy(self):
docs = render_chart(
values={
"executor": "CeleryExecutor",
"workers": {
"persistence": {
"enabled": True,
"persistentVolumeClaimRetentionPolicy": {"whenDeleted": "Delete"},
}
},
},
show_only=["templates/workers/worker-deployment.yaml"],
)

assert {
"whenDeleted": "Delete",
} == jmespath.search("spec.persistentVolumeClaimRetentionPolicy", docs[0])

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