Skip to content

fix: use promtool for listenLocal health probes#8672

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

fix: use promtool for listenLocal health probes#8672
SebTardif wants to merge 2 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

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>
@SebTardif SebTardif requested a review from a team as a code owner July 4, 2026 14:25
Comment thread pkg/operator/prober.go Outdated
Comment on lines +33 to +35
baseURL := u
if i := strings.Index(u, "/-/"); i >= 0 {
baseURL = u[:i]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @SebTardif as the ci issue notes this can be changed as

Suggested change
baseURL := u
if i := strings.Index(u, "/-/"); i >= 0 {
baseURL = u[:i]
baseURL, _, _ := strings.Cut(u, "/-/")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 05c75f1 — switched to strings.Cut as suggested.

Satisfy modernize/stringscut (golangci-lint) as noted in review.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
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.

2 participants