This is an automated email from the ASF dual-hosted git repository.
Miretpl 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 81b93db4a2f Fix StatsD not restarting when overrideMappings or
cache.ttl changes (#72633)
81b93db4a2f is described below
commit 81b93db4a2f6da3d4e56a337f0f0b84fb2f1b029
Author: Y-C <[email protected]>
AuthorDate: Sun Sep 13 05:01:45 2026 +0800
Fix StatsD not restarting when overrideMappings or cache.ttl changes
(#72633)
* Fix StatsD not restarting when overrideMappings or cache.ttl changes
The checksum annotation that rolls the StatsD pod was only rendered when
extraMappings or podAnnotations was set, so changing overrideMappings or
cache.ttl updated the ConfigMap without restarting the pod and the
exporter silently kept the old mappings.
The checksum is also narrowed to the ConfigMap data so that chart version
bumps and other metadata-only changes no longer restart StatsD.
* Hash the whole StatsD ConfigMap document for the rollout checksum
Narrowing the checksum to the ConfigMap's .data made StatsD the only
component in the chart whose pods do not roll on a chart version bump.
Review preferred keeping the same full-document hash every other
component uses: a restart of the stateless StatsD exporter on upgrade
is cheap, and a change we would want to roll out for but did not
anticipate is not.
* Keep the podAnnotations block in its original form
The if-to-with rewrite was a cosmetic change unrelated to the rollout fix
and was flagged as unnecessary in review.
---------
Co-authored-by: Eason09053360
<[email protected]>
---
chart/templates/statsd/statsd-deployment.yaml | 2 --
chart/tests/helm_tests/other/test_statsd.py | 23 +++++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/chart/templates/statsd/statsd-deployment.yaml
b/chart/templates/statsd/statsd-deployment.yaml
index 842ab983752..4976d84704e 100644
--- a/chart/templates/statsd/statsd-deployment.yaml
+++ b/chart/templates/statsd/statsd-deployment.yaml
@@ -64,13 +64,11 @@ spec:
{{- if or .Values.labels .Values.statsd.labels }}
{{- mustMerge .Values.statsd.labels .Values.labels | toYaml |
nindent 8 }}
{{- end }}
- {{- if or .Values.statsd.extraMappings .Values.statsd.podAnnotations }}
annotations:
checksum/statsd-config: {{ include (print $.Template.BasePath
"/configmaps/statsd-configmap.yaml") . | sha256sum }}
{{- if .Values.statsd.podAnnotations }}
{{- tpl (toYaml .Values.statsd.podAnnotations) . | nindent 8 }}
{{- end }}
- {{- end }}
spec:
{{- if .Values.statsd.priorityClassName }}
priorityClassName: {{ .Values.statsd.priorityClassName }}
diff --git a/chart/tests/helm_tests/other/test_statsd.py
b/chart/tests/helm_tests/other/test_statsd.py
index 27016af67d6..da6d6d5a332 100644
--- a/chart/tests/helm_tests/other/test_statsd.py
+++ b/chart/tests/helm_tests/other/test_statsd.py
@@ -355,6 +355,29 @@ class TestStatsd:
jmespath.search("spec.template.metadata.annotations",
docs[0])["test_pod_annotation"]
== "test_pod_annotation_value"
)
+ assert "checksum/statsd-config" in
jmespath.search("spec.template.metadata.annotations", docs[0])
+
+ @pytest.mark.parametrize(
+ "statsd_values",
+ [
+ pytest.param(
+ {"overrideMappings": [{"match": "foo.*", "name": "foo",
"match_type": "regex"}]},
+ id="overrideMappings",
+ ),
+ pytest.param({"cache": {"ttl": "10m"}}, id="cache-ttl"),
+ ],
+ )
+ def test_configmap_checksum_should_change_with_configmap_data(self,
statsd_values):
+ def get_checksum(values):
+ docs = render_chart(
+ values={"statsd": {"enabled": True, **values}},
+ show_only=["templates/statsd/statsd-deployment.yaml"],
+ )
+ annotations =
jmespath.search("spec.template.metadata.annotations", docs[0]) or {}
+ assert "checksum/statsd-config" in annotations
+ return annotations["checksum/statsd-config"]
+
+ assert get_checksum(statsd_values) != get_checksum({})
def test_should_add_custom_env_variables(self):
env1 = {"name": "TEST_ENV_1", "value": "test_env_1"}