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 7f0332de2d Enhance chart to allow over-riding command-line args to 
statsd exporter (#28041)
7f0332de2d is described below

commit 7f0332de2d1e57cde2e031f4bb7b4e6844c4b7c1
Author: Rob Caskey <[email protected]>
AuthorDate: Thu Dec 1 16:13:29 2022 -0500

    Enhance chart to allow over-riding command-line args to statsd exporter 
(#28041)
---
 chart/templates/statsd/statsd-deployment.yaml |  5 +++--
 chart/values.schema.json                      | 13 +++++++++++++
 chart/values.yaml                             |  3 +++
 tests/charts/test_statsd.py                   | 12 ++++++++++++
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/chart/templates/statsd/statsd-deployment.yaml 
b/chart/templates/statsd/statsd-deployment.yaml
index 58ac7cc547..b8d0323349 100644
--- a/chart/templates/statsd/statsd-deployment.yaml
+++ b/chart/templates/statsd/statsd-deployment.yaml
@@ -87,8 +87,9 @@ spec:
         - name: statsd
           image: {{ template "statsd_image" . }}
           imagePullPolicy: {{ .Values.images.statsd.pullPolicy }}
-          args:
-            - "--statsd.mapping-config=/etc/statsd-exporter/mappings.yml"
+          {{- if .Values.statsd.args }}
+          args: {{ tpl (toYaml .Values.statsd.args) . | nindent 12 }}
+          {{- end }}
           resources:
 {{ toYaml .Values.statsd.resources | indent 12 }}
           ports:
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 8a3048dc07..1144d471dd 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -4167,6 +4167,19 @@
                     "additionalProperties": {
                         "type": "string"
                     }
+                },
+                "args": {
+                    "description": "Args to use when running statsd-exporter 
(templated).",
+                    "type": [
+                        "array",
+                        "null"
+                    ],
+                    "items": {
+                        "type": "string"
+                    },
+                    "default": [
+                        
"--statsd.mapping-config=/etc/statsd-exporter/mappings.yml"
+                    ]
                 }
             }
         },
diff --git a/chart/values.yaml b/chart/values.yaml
index 4680eee74a..98c647bd73 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -1331,6 +1331,9 @@ statsd:
   # Max number of old replicasets to retain
   revisionHistoryLimit: ~
 
+  # Arguments for StatsD exporter command.
+  args: ["--statsd.mapping-config=/etc/statsd-exporter/mappings.yml"]
+
   # Create ServiceAccount
   serviceAccount:
     # Specifies whether a ServiceAccount should be created
diff --git a/tests/charts/test_statsd.py b/tests/charts/test_statsd.py
index 7ab1b1163e..7e7dbbab7c 100644
--- a/tests/charts/test_statsd.py
+++ b/tests/charts/test_statsd.py
@@ -41,6 +41,9 @@ class TestStatsd:
             "subPath": "mappings.yml",
         } in jmespath.search("spec.template.spec.containers[0].volumeMounts", 
docs[0])
 
+        default_args = 
["--statsd.mapping-config=/etc/statsd-exporter/mappings.yml"]
+        assert default_args == 
jmespath.search("spec.template.spec.containers[0].args", docs[0])
+
     def 
test_should_add_volume_and_volume_mount_when_exist_extra_mappings(self):
         extra_mapping = {
             "match": "airflow.pool.queued_slots.*",
@@ -210,3 +213,12 @@ class TestStatsd:
 
         assert 1 == len(mappings_yml_obj["mappings"])
         assert "airflow_pool_queued_slots" == 
mappings_yml_obj["mappings"][0]["name"]
+
+    def test_statsd_args_can_be_overridden(self):
+        args = ["--some-arg=foo"]
+        docs = render_chart(
+            values={"statsd": {"enabled": True, "args": args}},
+            show_only=["templates/statsd/statsd-deployment.yaml"],
+        )
+
+        assert jmespath.search("spec.template.spec.containers[0].args", 
docs[0]) == args

Reply via email to