From 67701c805f6397d8b025900ba4ad896900e80bc7 Mon Sep 17 00:00:00 2001 From: Robert Moucha Date: Sat, 29 Aug 2026 17:30:01 +0200 Subject: [PATCH] fix: don't render PodMonitor and HPA for disabled components The PodMonitor (or VMPodScrape) for proxy, broker, bookkeeper and autorecovery was guarded only by `.podMonitor.enabled`, which defaults to true, so it was rendered even when the component itself was disabled via `components.*=false`. This left scrape configs whose selectors match no pods: harmless to Prometheus, but permanent drift in GitOps setups and empty targets in dashboards. `proxy-hpa.yaml` and `broker-hpa.yaml` had the same missing guard. That case is rarer, since it also requires `autoscaling.enabled=true`, but the result is worse: the HPA targets a StatefulSet that was never created, so the controller sits at ScalingActive=False / FailedGetScale and emits warning events continuously. Add the missing `components.*` condition to all six templates, keeping the existing `standalone.enabled` checks. This matches what the zookeeper, function-worker and oxia pod monitors already do, and what every other template belonging to these components already does. Fixes #716 --- charts/pulsar/templates/autorecovery-podmonitor.yaml | 4 ++-- charts/pulsar/templates/bookkeeper-podmonitor.yaml | 4 ++-- charts/pulsar/templates/broker-hpa.yaml | 2 +- charts/pulsar/templates/broker-podmonitor.yaml | 4 ++-- charts/pulsar/templates/proxy-hpa.yaml | 2 +- charts/pulsar/templates/proxy-podmonitor.yaml | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/charts/pulsar/templates/autorecovery-podmonitor.yaml b/charts/pulsar/templates/autorecovery-podmonitor.yaml index a141b37c..2683baee 100644 --- a/charts/pulsar/templates/autorecovery-podmonitor.yaml +++ b/charts/pulsar/templates/autorecovery-podmonitor.yaml @@ -17,7 +17,7 @@ # under the License. # -# deploy autorecovery PodMonitor only when `$.Values.autorecovery.podMonitor.enabled` is true -{{- if and $.Values.autorecovery.podMonitor.enabled (not $.Values.standalone.enabled) }} +# deploy autorecovery PodMonitor only when the autorecovery component and `$.Values.autorecovery.podMonitor.enabled` are both enabled +{{- if and $.Values.components.autorecovery $.Values.autorecovery.podMonitor.enabled (not $.Values.standalone.enabled) }} {{- include "pulsar.podMonitor" (list . "autorecovery" (printf "component: %s" .Values.autorecovery.component)) }} {{- end }} \ No newline at end of file diff --git a/charts/pulsar/templates/bookkeeper-podmonitor.yaml b/charts/pulsar/templates/bookkeeper-podmonitor.yaml index 005e22b4..08fb7bf3 100644 --- a/charts/pulsar/templates/bookkeeper-podmonitor.yaml +++ b/charts/pulsar/templates/bookkeeper-podmonitor.yaml @@ -17,7 +17,7 @@ # under the License. # -# deploy bookkeeper PodMonitor only when `$.Values.bookkeeper.podMonitor.enabled` is true -{{- if and $.Values.bookkeeper.podMonitor.enabled (not $.Values.standalone.enabled) }} +# deploy bookkeeper PodMonitor only when the bookkeeper component and `$.Values.bookkeeper.podMonitor.enabled` are both enabled +{{- if and $.Values.components.bookkeeper $.Values.bookkeeper.podMonitor.enabled (not $.Values.standalone.enabled) }} {{- include "pulsar.podMonitor" (list . "bookkeeper" (printf "component: %s" .Values.bookkeeper.component)) }} {{- end }} \ No newline at end of file diff --git a/charts/pulsar/templates/broker-hpa.yaml b/charts/pulsar/templates/broker-hpa.yaml index d165c33c..aec40615 100644 --- a/charts/pulsar/templates/broker-hpa.yaml +++ b/charts/pulsar/templates/broker-hpa.yaml @@ -17,7 +17,7 @@ # under the License. # -{{- if and .Values.broker.autoscaling.enabled (not .Values.standalone.enabled) }} +{{- if and .Values.components.broker .Values.broker.autoscaling.enabled (not .Values.standalone.enabled) }} {{- if (semverCompare "<1.23-0" .Capabilities.KubeVersion.Version) }} apiVersion: autoscaling/v2beta2 {{- else }} diff --git a/charts/pulsar/templates/broker-podmonitor.yaml b/charts/pulsar/templates/broker-podmonitor.yaml index 16e332d2..f041f60e 100644 --- a/charts/pulsar/templates/broker-podmonitor.yaml +++ b/charts/pulsar/templates/broker-podmonitor.yaml @@ -17,7 +17,7 @@ # under the License. # -# deploy broker PodMonitor only when `$.Values.broker.podMonitor.enabled` is true -{{- if and $.Values.broker.podMonitor.enabled (not $.Values.standalone.enabled) }} +# deploy broker PodMonitor only when the broker component and `$.Values.broker.podMonitor.enabled` are both enabled +{{- if and $.Values.components.broker $.Values.broker.podMonitor.enabled (not $.Values.standalone.enabled) }} {{- include "pulsar.podMonitor" (list . "broker" (printf "component: %s" .Values.broker.component)) }} {{- end }} \ No newline at end of file diff --git a/charts/pulsar/templates/proxy-hpa.yaml b/charts/pulsar/templates/proxy-hpa.yaml index b190560a..106a26af 100644 --- a/charts/pulsar/templates/proxy-hpa.yaml +++ b/charts/pulsar/templates/proxy-hpa.yaml @@ -17,7 +17,7 @@ # under the License. # -{{- if .Values.proxy.autoscaling.enabled }} +{{- if and .Values.components.proxy .Values.proxy.autoscaling.enabled }} {{- if (semverCompare "<1.23-0" .Capabilities.KubeVersion.Version) }} apiVersion: autoscaling/v2beta2 {{- else }} diff --git a/charts/pulsar/templates/proxy-podmonitor.yaml b/charts/pulsar/templates/proxy-podmonitor.yaml index e4e7b237..4c611232 100644 --- a/charts/pulsar/templates/proxy-podmonitor.yaml +++ b/charts/pulsar/templates/proxy-podmonitor.yaml @@ -17,7 +17,7 @@ # under the License. # -# deploy proxy PodMonitor only when `$.Values.proxy.podMonitor.enabled` is true -{{- if $.Values.proxy.podMonitor.enabled }} +# deploy proxy PodMonitor only when the proxy component and `$.Values.proxy.podMonitor.enabled` are both enabled +{{- if and $.Values.components.proxy $.Values.proxy.podMonitor.enabled }} {{- include "pulsar.podMonitor" (list . "proxy" (printf "component: %s" .Values.proxy.component) "sts-http") }} {{- end }} \ No newline at end of file