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 ed57711866 Add annotations for Redis StatefulSet (#40281)
ed57711866 is described below

commit ed57711866527d4e56ce195944b26607317b1f26
Author: Masoud Arbabi <[email protected]>
AuthorDate: Fri Jun 21 16:57:19 2024 +0200

    Add annotations for Redis StatefulSet (#40281)
---
 chart/templates/redis/redis-statefulset.yaml |  3 +++
 chart/values.schema.json                     |  8 ++++++++
 chart/values.yaml                            |  3 +++
 helm_tests/airflow_aux/test_annotations.py   | 26 ++++++++++++++++++++++++++
 4 files changed, 40 insertions(+)

diff --git a/chart/templates/redis/redis-statefulset.yaml 
b/chart/templates/redis/redis-statefulset.yaml
index 5aa9e13598..cbc504e0a5 100644
--- a/chart/templates/redis/redis-statefulset.yaml
+++ b/chart/templates/redis/redis-statefulset.yaml
@@ -41,6 +41,9 @@ metadata:
     {{- with .Values.labels }}
       {{- toYaml . | nindent 4 }}
     {{- end }}
+  {{- if .Values.redis.annotations }}
+  annotations: {{- toYaml .Values.redis.annotations | nindent 4 }}
+  {{- end }}
 spec:
   serviceName: {{ include "airflow.fullname" . }}-redis
   selector:
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 4b4b8af381..fed2168ea7 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -7611,6 +7611,14 @@
                     "additionalProperties": {
                         "type": "string"
                     }
+                },
+                "annotations": {
+                    "description": "Annotations for the redis.",
+                    "type": "object",
+                    "default": {},
+                    "additionalProperties": {
+                        "type": "string"
+                    }
                 }
             }
         },
diff --git a/chart/values.yaml b/chart/values.yaml
index 478ed2e49b..c623f3e9dd 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -2230,6 +2230,9 @@ redis:
   enabled: true
   terminationGracePeriodSeconds: 600
 
+  # Annotations for Redis Statefulset
+  annotations: {}
+
   # Create ServiceAccount
   serviceAccount:
     # default value is true
diff --git a/helm_tests/airflow_aux/test_annotations.py 
b/helm_tests/airflow_aux/test_annotations.py
index 8f297bf73b..902bacd755 100644
--- a/helm_tests/airflow_aux/test_annotations.py
+++ b/helm_tests/airflow_aux/test_annotations.py
@@ -426,3 +426,29 @@ class TestPerComponentPodAnnotations:
         for k, v in expected_annotations.items():
             assert k in annotations
             assert v == annotations[k]
+
+
+class TestRedisAnnotations:
+    """Tests Redis Annotations."""
+
+    def test_redis_annotations_are_added(self):
+        # Test Case
+        values = {"redis": {"annotations": {"example": "redis"}}}
+        show_only = "templates/redis/redis-statefulset.yaml"
+        expected_annotations = {"example": "redis"}
+
+        k8s_objects = render_chart(
+            values=values,
+            show_only=[show_only],
+        )
+
+        # This test relies on the convention that the helm chart puts 
annotations
+        # in its own .yaml file, so by specifying `show_only`,
+        # we should only get a single k8s_object here - the target object that
+        # we hope to test on.
+        assert len(k8s_objects) == 1
+        obj = k8s_objects[0]
+
+        for k, v in expected_annotations.items():
+            assert k in obj["metadata"]["annotations"]
+            assert v == obj["metadata"]["annotations"][k]

Reply via email to