Skip to content

Commit f4c1adf

Browse files
fix: capture Run() error in metrics controller goroutine
The goroutine was referencing the outer 'err' variable from metrics.NewController() instead of capturing the return value from metricsController.Run(). By the time the goroutine executes, the outer err is nil (NewController succeeded), so the log line always printed a nil error — making failures impossible to diagnose. Fixes #325
1 parent 0974487 commit f4c1adf

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,14 @@ func main() {
287287
externalScaler := externalscaler.NewExternalScaler(mgr.GetClient())
288288
go func() {
289289
grpcServer := grpc.NewServer()
290-
lis, _ := net.Listen("tcp", scaleServerAddr)
290+
lis, err := net.Listen("tcp", scaleServerAddr)
291+
if err != nil {
292+
setupLog.Error(err, "unable to listen for ExternalScalerServer", "address", scaleServerAddr)
293+
os.Exit(1)
294+
}
291295
externalscaler.RegisterExternalScalerServer(grpcServer, externalScaler)
292296
if err := grpcServer.Serve(lis); err != nil {
293-
setupLog.Error(err, "unable to setup ExternalScalerServer")
297+
setupLog.Error(err, "unable to serve ExternalScalerServer")
294298
os.Exit(1)
295299
}
296300
}()

0 commit comments

Comments
 (0)