Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix allocator metrics endpoint #3921

Merged
merged 4 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmd/allocator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ func main() {
if !validPort(conf.GRPCPort) && !validPort(conf.HTTPPort) {
logger.WithField("grpc-port", conf.GRPCPort).WithField("http-port", conf.HTTPPort).Fatal("Must specify a valid gRPC port or an HTTP port for the allocator service")
}

health, closer := setupMetricsRecorder(conf)
healthserver := &httpserver.Server{Logger: logger}
health, closer := setupMetricsRecorder(conf, healthserver)
defer closer()

kubeClient, agonesClient, err := getClients(conf)
Expand Down Expand Up @@ -307,7 +307,6 @@ func main() {
}

// Finally listen on 8080 (http), used to serve /live and /ready handlers for Kubernetes probes.
healthserver := httpserver.Server{Logger: logger}
healthserver.Handle("/", health)
go func() { _ = healthserver.Run(listenCtx, 0) }()

Expand Down
7 changes: 3 additions & 4 deletions cmd/allocator/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
package main

import (
"net/http"

"agones.dev/agones/pkg/metrics"
"agones.dev/agones/pkg/util/httpserver"
"github.com/heptiolabs/healthcheck"
prom "github.com/prometheus/client_golang/prometheus"
"go.opencensus.io/plugin/ocgrpc"
Expand All @@ -33,7 +32,7 @@ func registerMetricViews() {
}
}

func setupMetricsRecorder(conf config) (health healthcheck.Handler, closer func()) {
func setupMetricsRecorder(conf config, healthserver *httpserver.Server) (health healthcheck.Handler, closer func()) {
health = healthcheck.NewHandler()
closer = func() {}

Expand All @@ -54,7 +53,7 @@ func setupMetricsRecorder(conf config) (health healthcheck.Handler, closer func(
if err != nil {
logger.WithError(err).Fatal("Could not register prometheus exporter")
}
http.Handle("/metrics", metricHandler)
healthserver.Handle("/metrics", metricHandler)
health = healthcheck.NewMetricsHandler(registry, "agones")
}

Expand Down
Loading