Skip to content

fix: use promtool for listenLocal health probes - #8672

Open
SebTardif wants to merge 3 commits into
prometheus-operator:mainfrom
SebTardif:fix/listenlocal-promtool-probes
Open

fix: use promtool for listenLocal health probes#8672
SebTardif wants to merge 3 commits into
prometheus-operator:mainfrom
SebTardif:fix/listenlocal-promtool-probes

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

Summary

When listenLocal: true, probes used sh -c with curl/wget. Distroless images (default in kube-prometheus-stack) do not include those tools, so readiness/liveness fail permanently.

Fix

Use promtool check healthy|ready --url=http://localhost:9090 for listenLocal probes. promtool ships in official Prometheus images.

Testing

  • go test ./pkg/operator/ -run TestProbers
  • Updated listenLocal expectations in statefulset_test.go

Ref #8605

@SebTardif
SebTardif requested a review from a team as a code owner July 4, 2026 14:25
Comment thread pkg/operator/prober.go Outdated

@simonpasquier simonpasquier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check the Prometheus version because promtool check healthy|ready was added in 2.44.0.

@simonpasquier simonpasquier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd need an end-to-end test validating the 2 scenarios

  • busybox image with listenLocal: true
  • distroless image with listenLocal: true

Comment thread pkg/operator/prober.go
Distroless Prometheus images lack sh/curl/wget, so exec probes built with
a shell wrapper always fail when listenLocal is true. Probe with promtool
check healthy/ready against localhost instead.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Satisfy modernize/stringscut (golangci-lint) as noted in review.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
Restore shell-based ExecAction for config-reloader and pre-2.44
Prometheus, add PromtoolExecAction for distroless Prometheus images,
and gate promtool on version 2.44.0+. Cover both packaging styles in e2e.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@SebTardif
SebTardif force-pushed the fix/listenlocal-promtool-probes branch from 05c75f1 to 1fe5a12 Compare July 15, 2026 14:50
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jul 15, 2026
@SebTardif

Copy link
Copy Markdown
Contributor Author

@simonpasquier

We need to check the Prometheus version because promtool check healthy|ready was added in 2.44.0.

Done in 1fe5a12. buildProbeHandler uses PromtoolExecAction only when the Prometheus version is at least 2.44.0; older versions keep the shell-based ExecAction.

Ideally we'd need an end-to-end test validating the 2 scenarios

  • busybox image with listenLocal: true
  • distroless image with listenLocal: true

Added testPromListenLocalReady (registered as PromListenLocalReady) covering both packaging styles:

  • distroless: quay.io/prometheus/prometheus:<version>-distroless
  • busybox-based: default quay.io/prometheus/prometheus:<version>

Also:

  • unit coverage for ExecAction, PromtoolExecAction, and pre-2.44 listenLocal probes
  • rebased onto current main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants