apache / apache/pulsar-helm-chart
PodMonitor and HPA are rendered for disabled components (proxy, broker, bookkeeper, autorecovery)
- Dominant language
- Shell
- Stars
- 240
- Forks
- 260
- Avg merge
- 4h 12m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
The `PodMonitor` (or `VMPodScrape`, when `victoria-metrics-k8s-stack` is enabled) for the proxy, broker, bookkeeper and autorecovery components is rendered even when the component itself is disabled via `components.*=false`.
These four templates are guarded only by `.podMonitor.enabled`, which defaults to `true`, and never check `.Values.components.*`:
| Template | Current guard |
|---|---|
| `charts/pulsar/templates/proxy-podmonitor.yaml` | `if $.Values.proxy.podMonitor.enabled` |
| `charts/pulsar/templates/broker-podmonitor.yaml` | `if and $.Values.broker.podMonitor.enabled (not $.Values.standalone.enabled)` |
| `charts/pulsar/templates/bookkeeper-podmonitor.yaml` | `if and $.Values.bookkeeper.podMonitor.enabled (not $.Values.standalone.enabled)` |
| `charts/pulsar/templates/autorecovery-podmonitor.yaml` | `if and $.Values.autorecovery.podMonitor.enabled (not $.Values.standalone.enabled)` |
The remaining pod monitors already do this correctly — `zookeeper-podmonitor.yaml` checks `components.zookeeper`, `function-worker-podmonitor.yaml` checks `components.function_worker`, and both oxia monitors check `components.oxia`. Every other template belonging to these four components (statefulset, service, configmap, pdb, service-account) is gated on `components.*`, so the pod monitors are the only outliers.
`charts/pulsar/templates/proxy-hpa.yaml` and `charts/pulsar/templates/broker-hpa.yaml` have the same missing guard — they check only `.autoscaling.enabled` (and, for the broker, `standalone.enabled`). Because `autoscaling.enabled` defaults to `false` this affects fewer users, but the consequence is worse than a stray pod monitor: the HPA targets a StatefulSet that was never created, so the HPA controller reports `ScalingActive=False` / `FailedGetScale` and emits warning events continuously.
**To Reproduce**
Pod monitors:
```console
$ 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 \
| awk '/^# Source:/{src=$3} /^kind: (PodMonitor|VMPodScrape)/{print $2, src}'
VMPodScrape pulsar/templates/autorecovery-podmonitor.yaml
VMPodScrape pulsar/templates/bookkeeper-podmonitor.yaml
VMPodScrape pulsar/templates/broker-podmonitor.yaml
VMPodScrape pulsar/templates/proxy-podmonitor.yaml
```
Only the zookeeper monitor is correctly omitted.
HPAs:
```console
$ helm template t charts/pulsar \
--set components.proxy=false --set components.broker=false \
--set proxy.autoscaling.enabled=true --set broker.autoscaling.enabled=true \
| awk '/^# Source:/{src=$3} /^kind: HorizontalPodAutoscaler/{print $2, src}'
HorizontalPodAutoscaler pulsar/templates/broker-hpa.yaml
HorizontalPodAutoscaler pulsar/templates/proxy-hpa.yaml
```
Working around either case requires disabling the same component twice, e.g. `components.proxy=false` **and** `proxy.podMonitor.enabled=false`.
**Expected behavior**
Disabling a component should not render its pod monitor or its HPA. `components.=false` should be sufficient on its own, consistent with how zookeeper, function-worker and oxia already behave.
**Impact**
- Pod monitors: the chart installs scrape configs whose selectors match no pods. Prometheus/VictoriaMetrics tolerate this, so nothing fails, but it leaves orphaned resources that show as permanent drift in GitOps setups, plus empty targets and dashboard series for a component the user explicitly turned off.
- HPAs: an autoscaler pointing at a non-existent scale target stays permanently degraded and generates recurring warning events.
- Both cases make `components.=false` mean less than it appears to.
**Suggested solution**
Add the missing `components.*` condition to the six templates, e.g. in `proxy-podmonitor.yaml`:
```gotemplate
{{- if and .Values.components.proxy $.Values.proxy.podMonitor.enabled }}
```
and equivalently for broker, bookkeeper and autorecovery, plus `proxy-hpa.yaml` and `broker-hpa.yaml` — keeping the existing `standalone.enabled` checks where present.
Note this is technically a behavior change for anyone who currently sets `components.=false` and depends on the stray resource being present — unlikely, but worth a line in the release notes.
**System configuration**
- Chart version: 4.7.0 (`charts/pulsar`, `master` @ `3288460`)
- appVersion: 4.0.12
- Reproduced with `helm template`; independent of Kubernetes version.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with charts/pulsar/templates/proxy-podmonitor.yaml, broker-podmonitor.yaml, bookkeeper-podmonitor.yaml, autorecovery-podmonitor.yaml, proxy-hpa.yaml, and broker-hpa.yaml. Run the provided helm template commands to reproduce the unwanted resources, then verify that disabling each component omits its PodMonitor or HPA while existing standalone checks remain effective.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- helm, kubernetes
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100