Skip to content

Commit

Permalink
Rename the autoscaling option
Browse files Browse the repository at this point in the history
* Renamed the "AtomicScaling" autoscaling option to
  "ZeroOrMaxNodeScaling" to be more clear about the behavior.
  • Loading branch information
hbostan committed Jun 30, 2023
1 parent 8ba34ea commit 333a028
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (tng *TestNodeGroup) DeleteNodes(nodes []*apiv1.Node) error {
id := tng.id
tng.targetSize -= len(nodes)
tng.Unlock()
if tng.opts != nil && tng.opts.AtomicScaling && tng.targetSize != 0 {
if tng.opts != nil && tng.opts.ZeroOrMaxNodeScaling && tng.targetSize != 0 {
return fmt.Errorf("TestNodeGroup: attempted to partially scale down a node group that should be scaled down atomically")
}
for _, node := range nodes {
Expand Down
4 changes: 2 additions & 2 deletions cluster-autoscaler/config/autoscaling_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type NodeGroupAutoscalingOptions struct {
ScaleDownUnreadyTime time.Duration
// Maximum time CA waits for node to be provisioned
MaxNodeProvisionTime time.Duration
// AtomicScaling means that a node group should be scaled up or down all at once instead of one-by-one
AtomicScaling bool
// ZeroOrMaxNodeScaling means that a node group should be scaled up to maximum size or down to zero nodes all at once instead of one-by-one.
ZeroOrMaxNodeScaling bool
}

// GCEOptions contain autoscaling options specific to GCE cloud provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ func TestStartDeletionInBatchBasic(t *testing.T) {
func sizedNodeGroup(id string, size int, atomic bool) cloudprovider.NodeGroup {
ng := testprovider.NewTestNodeGroup(id, 10000, 0, size, true, false, "n1-standard-2", nil, nil)
ng.SetOptions(&config.NodeGroupAutoscalingOptions{
AtomicScaling: atomic,
ZeroOrMaxNodeScaling: atomic,
})
return ng
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (ds *GroupDeletionScheduler) ScheduleDeletion(nodeInfo *framework.NodeInfo,
return
}

ds.addToBatcher(nodeInfo, nodeGroup, batchSize, drain, opts.AtomicScaling)
ds.addToBatcher(nodeInfo, nodeGroup, batchSize, drain, opts.ZeroOrMaxNodeScaling)
}

// prepareNodeForDeletion is a long-running operation, so it needs to avoid locking the AtomicDeletionScheduler object
Expand Down
4 changes: 2 additions & 2 deletions cluster-autoscaler/core/scaledown/budgets/budgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (bp *ScaleDownBudgetProcessor) categorize(groups []*NodeGroupView) (individ
klog.Errorf("Failed to get autoscaling options for node group %s: %v", view.Group.Id(), err)
continue
}
if autoscalingOptions != nil && autoscalingOptions.AtomicScaling {
if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling {
atomic = append(atomic, view)
} else {
individual = append(individual, view)
Expand All @@ -196,7 +196,7 @@ func (bp *ScaleDownBudgetProcessor) groupByNodeGroup(nodes []*apiv1.Node) (indiv
klog.Errorf("Failed to get autoscaling options for node group %s: %v", nodeGroup.Id(), err)
continue
}
if autoscalingOptions != nil && autoscalingOptions.AtomicScaling {
if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling {
if idx, ok := atomicGroup[nodeGroup]; ok {
atomic[idx].Nodes = append(atomic[idx].Nodes, node)
} else {
Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/core/scaledown/budgets/budgets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ var transformNodeGroupView = cmp.Transformer("transformNodeGroupView", func(b No
func sizedNodeGroup(id string, size int, atomic bool) cloudprovider.NodeGroup {
ng := testprovider.NewTestNodeGroup(id, 10000, 0, size, true, false, "n1-standard-2", nil, nil)
ng.SetOptions(&config.NodeGroupAutoscalingOptions{
AtomicScaling: atomic,
ZeroOrMaxNodeScaling: atomic,
})
return ng
}
Expand Down
2 changes: 1 addition & 1 deletion cluster-autoscaler/core/scaledown/planner/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ func TestNodesToDelete(t *testing.T) {
func sizedNodeGroup(id string, size int, atomic bool) cloudprovider.NodeGroup {
ng := testprovider.NewTestNodeGroup(id, 10000, 0, size, true, false, "n1-standard-2", nil, nil)
ng.SetOptions(&config.NodeGroupAutoscalingOptions{
AtomicScaling: atomic,
ZeroOrMaxNodeScaling: atomic,
})
return ng
}
Expand Down
6 changes: 3 additions & 3 deletions cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (o *ScaleUpOrchestrator) filterValidScaleUpNodeGroups(
klog.Errorf("Couldn't get autoscaling options for ng: %v", nodeGroup.Id())
}
numNodes := 1
if autoscalingOptions != nil && autoscalingOptions.AtomicScaling {
if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling {
numNodes = nodeGroup.MaxSize() - currentTargetSize
if o.autoscalingContext.MaxNodesTotal != 0 && currentNodeCount+numNodes > o.autoscalingContext.MaxNodesTotal {
klog.V(4).Infof("Skipping node group %s - atomic scale-up exceeds cluster node count limit", nodeGroup.Id())
Expand Down Expand Up @@ -495,7 +495,7 @@ func (o *ScaleUpOrchestrator) ComputeExpansionOption(
if err != nil {
klog.Errorf("Failed to get autoscaling options for node group %s: %v", nodeGroup.Id(), err)
}
if autoscalingOptions != nil && autoscalingOptions.AtomicScaling {
if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling {
if option.NodeCount > 0 && option.NodeCount != nodeGroup.MaxSize() {
option.NodeCount = nodeGroup.MaxSize()
}
Expand Down Expand Up @@ -633,7 +633,7 @@ func (o *ScaleUpOrchestrator) ComputeSimilarNodeGroups(
if err != nil {
klog.Errorf("Failed to get autoscaling options for node group %s: %v", nodeGroup.Id(), err)
}
if autoscalingOptions != nil && autoscalingOptions.AtomicScaling {
if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ func TestMixedScaleUp(t *testing.T) {
simpleScaleUpTest(t, config, expectedResults)
}

func TestAtomicScaleUp(t *testing.T) {
func TestZeroOrMaxNodeScaling(t *testing.T) {
options := defaultOptions
options.NodeGroupDefaults.AtomicScaling = true
options.NodeGroupDefaults.ZeroOrMaxNodeScaling = true

optionsWithLimitedMaxCores := options
optionsWithLimitedMaxCores.MaxCoresTotal = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (p *PostFilteringScaleDownNodeProcessor) filterOutIncompleteAtomicNodeGroup
klog.Errorf("Failed to get autoscaling options for node group %s: %v", nodeGroup.Id(), err)
continue
}
if autoscalingOptions != nil && autoscalingOptions.AtomicScaling {
if autoscalingOptions != nil && autoscalingOptions.ZeroOrMaxNodeScaling {
klog.V(2).Infof("Considering node %s for atomic scale down", node.Node.Name)
nodesByGroup[nodeGroup] = append(nodesByGroup[nodeGroup], node)
} else {
Expand Down

0 comments on commit 333a028

Please sign in to comment.