diff --git a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go index a9d5ed1e9592..542e45c2d540 100644 --- a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go +++ b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go @@ -164,6 +164,9 @@ func (o *ScaleUpOrchestrator) ScaleUp( } } + // Finalize binpacking limiter. + o.processors.BinpackingLimiter.FinalizeBinpacking(o.autoscalingContext, options) + if len(options) == 0 { klog.V(1).Info("No expansion options") return &status.ScaleUpStatus{ diff --git a/cluster-autoscaler/core/test/common.go b/cluster-autoscaler/core/test/common.go index 78247b927927..35c582f5d127 100644 --- a/cluster-autoscaler/core/test/common.go +++ b/cluster-autoscaler/core/test/common.go @@ -357,14 +357,17 @@ func (p *MockBinpackingLimiter) InitBinpacking(context *context.AutoscalingConte p.requiredExpansionOptions = 1 } +// MarkProcessed is here to satisfy the interface. +func (p *MockBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) { +} + // StopBinpacking stops the binpacking early, if we already have requiredExpansionOptions i.e. 1. func (p *MockBinpackingLimiter) StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool { return len(evaluatedOptions) == p.requiredExpansionOptions } -// MarkProcessed is here to satisfy the interface. -func (p *MockBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) { - +// FinalizeBinpacking is here to satisfy the interface. +func (p *MockBinpackingLimiter) FinalizeBinpacking(context *context.AutoscalingContext, finalOptions []expander.Option) { } // NewBackoff creates a new backoff object diff --git a/cluster-autoscaler/processors/binpacking/binpacking_limiter.go b/cluster-autoscaler/processors/binpacking/binpacking_limiter.go index 3b3ab61ba3f1..e1396ecf79c7 100644 --- a/cluster-autoscaler/processors/binpacking/binpacking_limiter.go +++ b/cluster-autoscaler/processors/binpacking/binpacking_limiter.go @@ -25,8 +25,9 @@ import ( // BinpackingLimiter processes expansion options to stop binpacking early. type BinpackingLimiter interface { InitBinpacking(context *context.AutoscalingContext, nodeGroups []cloudprovider.NodeGroup) - StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool MarkProcessed(context *context.AutoscalingContext, nodegroupId string) + StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool + FinalizeBinpacking(context *context.AutoscalingContext, finalOptions []expander.Option) } // NoOpBinpackingLimiter returns true without processing expansion options. @@ -42,11 +43,15 @@ func NewDefaultBinpackingLimiter() BinpackingLimiter { func (p *NoOpBinpackingLimiter) InitBinpacking(context *context.AutoscalingContext, nodeGroups []cloudprovider.NodeGroup) { } +// MarkProcessed marks the nodegroup as processed. +func (p *NoOpBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) { +} + // StopBinpacking is used to make decsions on the evaluated expansion options. func (p *NoOpBinpackingLimiter) StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool { return false } -// MarkProcessed marks the nodegroup as processed. -func (p *NoOpBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) { +// FinalizeBinpacking is called to finalize the BinpackingLimiter. +func (p *NoOpBinpackingLimiter) FinalizeBinpacking(context *context.AutoscalingContext, finalOptions []expander.Option) { }