Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend BinpackingLimiter interface #6176

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
}
Loading