Skip to content

fix: don't render PodMonitor and HPA for disabled components - #717

Open
mouchar wants to merge 1 commit into
apache:masterfrom
mouchar:fix-standalone
Open

fix: don't render PodMonitor and HPA for disabled components#717
mouchar wants to merge 1 commit into
apache:masterfrom
mouchar:fix-standalone

Conversation

@mouchar

@mouchar mouchar commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #716

Motivation

The PodMonitor (or VMPodScrape, when victoria-metrics-k8s-stack is enabled) for the proxy, broker, bookkeeper and autorecovery components was guarded only by <component>.podMonitor.enabled, which defaults to true. As a result it was rendered even when the component itself was disabled via components.*=false, leaving scrape configs whose selectors match no pods — harmless to Prometheus, but permanent drift in GitOps setups and empty targets/series in dashboards. Disabling a component required disabling it twice.

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 consequence is worse: the HPA targets a StatefulSet that was never created, so the HPA controller sits at ScalingActive=False / FailedGetScale and emits warning events continuously.

The zookeeper, function-worker and oxia pod monitors already check components.*, as does every other template belonging to these four components (statefulset, service, configmap, pdb, service-account) — these six were the outliers.

Modifications

Added the missing components.* condition to six templates, keeping the existing standalone.enabled checks where present:

Template New guard
proxy-podmonitor.yaml and $.Values.components.proxy $.Values.proxy.podMonitor.enabled
broker-podmonitor.yaml and $.Values.components.broker $.Values.broker.podMonitor.enabled (not $.Values.standalone.enabled)
bookkeeper-podmonitor.yaml and $.Values.components.bookkeeper $.Values.bookkeeper.podMonitor.enabled (not $.Values.standalone.enabled)
autorecovery-podmonitor.yaml and $.Values.components.autorecovery $.Values.autorecovery.podMonitor.enabled (not $.Values.standalone.enabled)
proxy-hpa.yaml and .Values.components.proxy .Values.proxy.autoscaling.enabled
broker-hpa.yaml and .Values.components.broker .Values.broker.autoscaling.enabled (not .Values.standalone.enabled)

The now-stale # deploy <component> PodMonitor only when ... is true comment above each pod monitor guard was updated to match.

No new tests: the chart has no harness that can assert a resource is absent (the template checks in CI are kubeconform schema validation over rendered output), and adding one would be a larger change than the fix itself.

Verifying this change

Before the change, both of these rendered resources for components that were switched off; after it, both render nothing:

$ helm template t charts/pulsar \
    --set components.proxy=false --set components.broker=false \
    --set components.bookkeeper=false --set components.autorecovery=false \
    --set components.zookeeper=false \
    --set proxy.autoscaling.enabled=true --set broker.autoscaling.enabled=true \
  | awk '/^# Source:/{s=$3} /^kind: (PodMonitor|VMPodScrape|HorizontalPodAutoscaler)/{print $2, s}'

No behavior change with default values — all five pod monitors still render, and both HPAs still render with autoscaling.enabled=true.

Also verified locally: helm lint clean; the CI "all features enabled" renders (.ci/templates-all-values.yaml, and with the patch1 overlay, at --kube-version 1.36.0) and the .ci/clusters/values-standalone.yaml scenario all render successfully.

Note this is technically a behavior change for anyone who sets components.<component>=false and relies on the stray PodMonitor/HPA being present — unlikely, but may be worth a line in the release notes.

  • Make sure that the change passes the CI checks.

The PodMonitor (or VMPodScrape) for proxy, broker, bookkeeper and
autorecovery was guarded only by `<component>.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 apache#716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PodMonitor and HPA are rendered for disabled components (proxy, broker, bookkeeper, autorecovery)

1 participant