Skip to content

Commit

Permalink
Operator: fix bug where /-/ready and /-/healthy always returned 404 (#…
Browse files Browse the repository at this point in the history
…1252)

* operator: fix bug where /-/ready and /-/healthy always returned 404

controller-runtime must have at least one ready/healthy check for the endpoints to exist

* fix lint error, use healthz.Ping
  • Loading branch information
rfratto committed Jan 11, 2022
1 parent 0b8d63d commit 41cf32c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ for detailed information.

- [BUGFIX] Fix panic when using 'stdout' in automatic logging (@mapno)

- [BUGFIX] Grafana Agent Operator: The /-/ready and /-/healthy endpoints will
no longer always return 404 (@rfratto).

- [DEPRECATION] The node_exporter integration's `netdev_device_whitelist` field
is deprecated in favor of `netdev_device_include`. Support for the old field
name will be removed in a future version. (@rfratto)
Expand Down
8 changes: 8 additions & 0 deletions cmd/agent-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/grafana/agent/pkg/operator/logutil"
"github.com/prometheus/common/version"
controller "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"

// Needed for clients.
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand All @@ -33,6 +34,13 @@ func main() {
os.Exit(1)
}

if err := m.AddReadyzCheck("running", healthz.Ping); err != nil {
level.Warn(logger).Log("msg", "failed to set up 'running' readyz check", "err", err)
}
if err := m.AddHealthzCheck("running", healthz.Ping); err != nil {
level.Warn(logger).Log("msg", "failed to set up 'running' healthz check", "err", err)
}

if err := operator.New(logger, cfg, m); err != nil {
level.Error(logger).Log("msg", "unable to create operator", "err", err)
os.Exit(1)
Expand Down

0 comments on commit 41cf32c

Please sign in to comment.