Skip to content

Commit bafcc0d

Browse files
authored
Merge pull request #6176 from BigDarkClown/extend-bl
Extend BinpackingLimiter interface
2 parents e9a698f + 81a4721 commit bafcc0d

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ func (o *ScaleUpOrchestrator) ScaleUp(
164164
}
165165
}
166166

167+
// Finalize binpacking limiter.
168+
o.processors.BinpackingLimiter.FinalizeBinpacking(o.autoscalingContext, options)
169+
167170
if len(options) == 0 {
168171
klog.V(1).Info("No expansion options")
169172
return &status.ScaleUpStatus{

cluster-autoscaler/core/test/common.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,17 @@ func (p *MockBinpackingLimiter) InitBinpacking(context *context.AutoscalingConte
357357
p.requiredExpansionOptions = 1
358358
}
359359

360+
// MarkProcessed is here to satisfy the interface.
361+
func (p *MockBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) {
362+
}
363+
360364
// StopBinpacking stops the binpacking early, if we already have requiredExpansionOptions i.e. 1.
361365
func (p *MockBinpackingLimiter) StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool {
362366
return len(evaluatedOptions) == p.requiredExpansionOptions
363367
}
364368

365-
// MarkProcessed is here to satisfy the interface.
366-
func (p *MockBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) {
367-
369+
// FinalizeBinpacking is here to satisfy the interface.
370+
func (p *MockBinpackingLimiter) FinalizeBinpacking(context *context.AutoscalingContext, finalOptions []expander.Option) {
368371
}
369372

370373
// NewBackoff creates a new backoff object

cluster-autoscaler/processors/binpacking/binpacking_limiter.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ import (
2525
// BinpackingLimiter processes expansion options to stop binpacking early.
2626
type BinpackingLimiter interface {
2727
InitBinpacking(context *context.AutoscalingContext, nodeGroups []cloudprovider.NodeGroup)
28-
StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool
2928
MarkProcessed(context *context.AutoscalingContext, nodegroupId string)
29+
StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool
30+
FinalizeBinpacking(context *context.AutoscalingContext, finalOptions []expander.Option)
3031
}
3132

3233
// NoOpBinpackingLimiter returns true without processing expansion options.
@@ -42,11 +43,15 @@ func NewDefaultBinpackingLimiter() BinpackingLimiter {
4243
func (p *NoOpBinpackingLimiter) InitBinpacking(context *context.AutoscalingContext, nodeGroups []cloudprovider.NodeGroup) {
4344
}
4445

46+
// MarkProcessed marks the nodegroup as processed.
47+
func (p *NoOpBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) {
48+
}
49+
4550
// StopBinpacking is used to make decsions on the evaluated expansion options.
4651
func (p *NoOpBinpackingLimiter) StopBinpacking(context *context.AutoscalingContext, evaluatedOptions []expander.Option) bool {
4752
return false
4853
}
4954

50-
// MarkProcessed marks the nodegroup as processed.
51-
func (p *NoOpBinpackingLimiter) MarkProcessed(context *context.AutoscalingContext, nodegroupId string) {
55+
// FinalizeBinpacking is called to finalize the BinpackingLimiter.
56+
func (p *NoOpBinpackingLimiter) FinalizeBinpacking(context *context.AutoscalingContext, finalOptions []expander.Option) {
5257
}

0 commit comments

Comments
 (0)