Fix for the controller panic issue on metrics.enabled is false#486
Fix for the controller panic issue on metrics.enabled is false#486markmandel merged 1 commit intoagones-dev:masterfrom
Conversation
|
Build Failed 😱 Build Id: 88873928-136c-46d3-9beb-d0b67ece13de Build Logs |
|
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 ! |
markmandel
left a comment
There was a problem hiding this comment.
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).