Skip to content

Commit

Permalink
Merge pull request #6122 from pohly/informer-fix
Browse files Browse the repository at this point in the history
fix incomplete startup of informers + broken scale down
  • Loading branch information
k8s-ci-robot authored Sep 20, 2023
2 parents f9a7c7f + ade5e08 commit d447a6f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cluster-autoscaler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,16 +498,23 @@ func buildAutoscaler(debuggingSnapshotter debuggingsnapshot.DebuggingSnapshotter
Comparator: nodeInfoComparator,
}

stop := make(chan struct{})
informerFactory.Start(stop)

// These metrics should be published only once.
metrics.UpdateNapEnabled(autoscalingOptions.NodeAutoprovisioningEnabled)
metrics.UpdateCPULimitsCores(autoscalingOptions.MinCoresTotal, autoscalingOptions.MaxCoresTotal)
metrics.UpdateMemoryLimitsBytes(autoscalingOptions.MinMemoryTotal, autoscalingOptions.MaxMemoryTotal)

// Create autoscaler.
return core.NewAutoscaler(opts)
autoscaler, err := core.NewAutoscaler(opts)
if err != nil {
return nil, err
}

// Start informers. This must come after fully constructing the autoscaler because
// additional informers might have been registered in the factory during NewAutoscaler.
stop := make(chan struct{})
informerFactory.Start(stop)

return autoscaler, nil
}

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

0 comments on commit d447a6f

Please sign in to comment.