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 5f5ab80174 Support annotations on volumeClaimTemplates (#23433)
5f5ab80174 is described below

commit 5f5ab8017440330cfecd7b49497ba32605780b2b
Author: Jed Cunningham <[email protected]>
AuthorDate: Tue May 3 11:17:33 2022 -0600

    Support annotations on volumeClaimTemplates (#23433)
---
 chart/templates/redis/redis-statefulset.yaml        |  4 ++++
 chart/templates/scheduler/scheduler-deployment.yaml |  4 ++++
 chart/templates/workers/worker-deployment.yaml      |  4 ++++
 chart/values.schema.json                            | 16 ++++++++++++++++
 chart/values.yaml                                   |  4 ++++
 tests/charts/test_redis.py                          |  7 +++++++
 tests/charts/test_scheduler.py                      |  7 +++++++
 tests/charts/test_worker.py                         |  7 +++++++
 8 files changed, 53 insertions(+)

diff --git a/chart/templates/redis/redis-statefulset.yaml 
b/chart/templates/redis/redis-statefulset.yaml
index 7943407fc7..f1d6976396 100644
--- a/chart/templates/redis/redis-statefulset.yaml
+++ b/chart/templates/redis/redis-statefulset.yaml
@@ -100,6 +100,10 @@ spec:
   volumeClaimTemplates:
     - metadata:
         name: redis-db
+        {{- if .Values.redis.persistence.annotations }}
+        annotations:
+          {{- toYaml .Values.redis.persistence.annotations | nindent 10 }}
+        {{- end }}
       spec:
       {{- if .Values.redis.persistence.storageClassName }}
         storageClassName: {{ .Values.redis.persistence.storageClassName }}
diff --git a/chart/templates/scheduler/scheduler-deployment.yaml 
b/chart/templates/scheduler/scheduler-deployment.yaml
index 820995cb3b..9bba56b1f9 100644
--- a/chart/templates/scheduler/scheduler-deployment.yaml
+++ b/chart/templates/scheduler/scheduler-deployment.yaml
@@ -264,6 +264,10 @@ spec:
   volumeClaimTemplates:
     - metadata:
         name: logs
+        {{- if .Values.workers.persistence.annotations }}
+        annotations:
+          {{- toYaml .Values.workers.persistence.annotations | nindent 10 }}
+        {{- end }}
       spec:
       {{- if .Values.workers.persistence.storageClassName }}
         storageClassName: {{ .Values.workers.persistence.storageClassName }}
diff --git a/chart/templates/workers/worker-deployment.yaml 
b/chart/templates/workers/worker-deployment.yaml
index a972f27430..a1f51de0f5 100644
--- a/chart/templates/workers/worker-deployment.yaml
+++ b/chart/templates/workers/worker-deployment.yaml
@@ -320,6 +320,10 @@ spec:
   volumeClaimTemplates:
     - metadata:
         name: logs
+        {{- if .Values.workers.persistence.annotations }}
+        annotations:
+          {{- toYaml .Values.workers.persistence.annotations | nindent 10 }}
+        {{- end }}
       spec:
       {{- if .Values.workers.persistence.storageClassName }}
         storageClassName: {{ .Values.workers.persistence.storageClassName }}
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 2412c7ff59..53a8b06d1c 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -1266,6 +1266,14 @@
                             "description": "Execute init container to chown 
log directory. This is currently only needed in kind, due to usage of 
local-path provisioner.",
                             "type": "boolean",
                             "default": false
+                        },
+                        "annotations": {
+                            "description": "Annotations to add to worker 
volumes.",
+                            "type": "object",
+                            "default": {},
+                            "additionalProperties": {
+                                "type": "string"
+                            }
                         }
                     }
                 },
@@ -3781,6 +3789,14 @@
                                 "null"
                             ],
                             "default": null
+                        },
+                        "annotations": {
+                            "description": "Annotations to add to redis 
volumes.",
+                            "type": "object",
+                            "default": {},
+                            "additionalProperties": {
+                                "type": "string"
+                            }
                         }
                     }
                 },
diff --git a/chart/values.yaml b/chart/values.yaml
index 27d8abdc28..0ec7be6bdd 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -477,6 +477,8 @@ workers:
     # This is currently only needed in kind, due to usage
     # of local-path provisioner.
     fixPermissions: false
+    # Annotations to add to worker volumes
+    annotations: {}
 
   kerberosSidecar:
     # Enable kerberos sidecar
@@ -1315,6 +1317,8 @@ redis:
     size: 1Gi
     # If using a custom storageClass, pass name ref to all statefulSets here
     storageClassName:
+    # Annotations to add to redis volumes
+    annotations: {}
 
   resources: {}
   #  limits:
diff --git a/tests/charts/test_redis.py b/tests/charts/test_redis.py
index d544b51086..2659687c60 100644
--- a/tests/charts/test_redis.py
+++ b/tests/charts/test_redis.py
@@ -320,3 +320,10 @@ class RedisTest(unittest.TestCase):
         )
         annotations = jmespath.search("metadata.annotations", docs[0])
         assert annotations["helm.sh/hook-weight"] == "0"
+
+    def test_persistence_volume_annotations(self):
+        docs = render_chart(
+            values={"redis": {"persistence": {"annotations": {"foo": "bar"}}}},
+            show_only=["templates/redis/redis-statefulset.yaml"],
+        )
+        assert {"foo": "bar"} == 
jmespath.search("spec.volumeClaimTemplates[0].metadata.annotations", docs[0])
diff --git a/tests/charts/test_scheduler.py b/tests/charts/test_scheduler.py
index 9e19559e62..93a53b0857 100644
--- a/tests/charts/test_scheduler.py
+++ b/tests/charts/test_scheduler.py
@@ -548,3 +548,10 @@ class SchedulerTest(unittest.TestCase):
                 "memory": "2Gi",
             },
         } == jmespath.search("spec.template.spec.containers[1].resources", 
docs[0])
+
+    def test_persistence_volume_annotations(self):
+        docs = render_chart(
+            values={"executor": "LocalExecutor", "workers": {"persistence": 
{"annotations": {"foo": "bar"}}}},
+            show_only=["templates/scheduler/scheduler-deployment.yaml"],
+        )
+        assert {"foo": "bar"} == 
jmespath.search("spec.volumeClaimTemplates[0].metadata.annotations", docs[0])
diff --git a/tests/charts/test_worker.py b/tests/charts/test_worker.py
index 6f7a46f38b..017429bfed 100644
--- a/tests/charts/test_worker.py
+++ b/tests/charts/test_worker.py
@@ -547,3 +547,10 @@ class WorkerTest(unittest.TestCase):
                 "memory": "2Gi",
             },
         } == jmespath.search("spec.template.spec.containers[1].resources", 
docs[0])
+
+    def test_persistence_volume_annotations(self):
+        docs = render_chart(
+            values={"workers": {"persistence": {"annotations": {"foo": 
"bar"}}}},
+            show_only=["templates/workers/worker-deployment.yaml"],
+        )
+        assert {"foo": "bar"} == 
jmespath.search("spec.volumeClaimTemplates[0].metadata.annotations", docs[0])

Reply via email to