Skip to content

Commit

Permalink
Merge pull request kubernetes#6176 from BigDarkClown/extend-bl
Browse files Browse the repository at this point in the history
Extend BinpackingLimiter interface
  • Loading branch information
k8s-ci-robot committed Oct 6, 2023
2 parents e9a698f + 81a4721 commit bafcc0d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
9 changes: 6 additions & 3 deletions cluster-autoscaler/core/test/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions cluster-autoscaler/processors/binpacking/binpacking_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
}

0 comments on commit bafcc0d

Please sign in to comment.