-
Notifications
You must be signed in to change notification settings - Fork 819
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 for the controller panic issue on metrics.enabled is false #486
Conversation
Build Failed 😱 Build Id: 88873928-136c-46d3-9beb-d0b67ece13de Build Logs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM !
Build Succeeded 👏 Build Id: b88e0386-0bcb-4e0d-834b-802ef91c6538 The following development artifacts have been built, and will exist for the next 30 days:
To install this version:
|
Rather than use all this reflect (and generally we shouldn't need to) - and to avoid this messiness, why don't we try something more like this, where we dynamically append to WDYT? server := &httpServer{}
var rs []runner
var health healthcheck.Handler
if ctlConf.Metrics {
registry := prom.NewRegistry()
metricHandler, err := metrics.RegisterPrometheusExporter(registry)
if err != nil {
logger.WithError(err).Fatal("Could not create register prometheus exporter")
}
server.Handle("/metrics", metricHandler)
health = healthcheck.NewMetricsHandler(registry, "agones")
rs = append(rs, metrics.NewController(kubeClient, agonesClient, agonesInformerFactory))
} else {
health = healthcheck.NewHandler()
}
server.Handle("/", health)
allocationMutex := &sync.Mutex{}
gsController := gameservers.NewController(wh, health, allocationMutex,
ctlConf.MinPort, ctlConf.MaxPort, ctlConf.SidecarImage, ctlConf.AlwaysPullSidecar,
ctlConf.SidecarCPURequest, ctlConf.SidecarCPULimit,
kubeClient, kubeInformationFactory, extClient, agonesClient, agonesInformerFactory)
gsSetController := gameserversets.NewController(wh, health, allocationMutex,
kubeClient, extClient, agonesClient, agonesInformerFactory)
fleetController := fleets.NewController(wh, health, kubeClient, extClient, agonesClient, agonesInformerFactory)
faController := fleetallocation.NewController(wh, allocationMutex,
kubeClient, extClient, agonesClient, agonesInformerFactory)
gasController := gameserverallocations.NewController(wh, health, allocationMutex, kubeClient,
kubeInformationFactory, extClient, agonesClient, agonesInformerFactory)
fasController := fleetautoscalers.NewController(wh, health,
kubeClient, extClient, agonesClient, agonesInformerFactory)
rs = append(rs, wh, gsController, gsSetController, fleetController, faController, fasController, gasController, server)
stop := signals.NewStopChannel()
kubeInformationFactory.Start(stop)
agonesInformerFactory.Start(stop)
for _, r := range rs {
go func(rr runner) {
if runErr := rr.Run(workers, stop); runErr != nil {
logger.WithError(runErr).Fatalf("could not start runner: %s", reflect.TypeOf(rr))
}
}(r)
} |
I think it's a great idea ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then let's change this PR to do this then 😄
Force us to clean this section up.
If we disable metrics in Helm config file, Agones controller will panic on rr.Run() which could not be executed on non-nil interface with nil value (and not empty type of metrics.Controller).
Build Succeeded 👏 Build Id: 7d79a0f1-5675-4a72-9612-23bb0587be53 The following development artifacts have been built, and will exist for the next 30 days:
To install this version:
|
If we disable metrics in Helm config file, Agones controller will panic on Run() call which could not be executed on non-nil interface with nil value (and not empty type of metrics.Controller).