Skip to content

Commit d447a6f

Browse files
authored
Merge pull request #6122 from pohly/informer-fix
fix incomplete startup of informers + broken scale down
2 parents f9a7c7f + ade5e08 commit d447a6f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cluster-autoscaler/main.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,16 +498,23 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
498498
Comparator: nodeInfoComparator,
499499
}
500500

501-
stop := make(chan struct{})
502-
informerFactory.Start(stop)
503-
504501
// These metrics should be published only once.
505502
metrics.UpdateNapEnabled(autoscalingOptions.NodeAutoprovisioningEnabled)
506503
metrics.UpdateCPULimitsCores(autoscalingOptions.MinCoresTotal, autoscalingOptions.MaxCoresTotal)
507504
metrics.UpdateMemoryLimitsBytes(autoscalingOptions.MinMemoryTotal, autoscalingOptions.MaxMemoryTotal)
508505

509506
// Create autoscaler.
510-
return core.NewAutoscaler(opts)
507+
autoscaler, err := core.NewAutoscaler(opts)
508+
if err != nil {
509+
return nil, err
510+
}
511+
512+
// Start informers. This must come after fully constructing the autoscaler because
513+
// additional informers might have been registered in the factory during NewAutoscaler.
514+
stop := make(chan struct{})
515+
informerFactory.Start(stop)
516+
517+
return autoscaler, nil
511518
}
512519

513520
func run(healthCheck *metrics.HealthCheck, debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter) {

0 commit comments

Comments
 (0)