@@ -32,7 +32,6 @@ import (
32
32
"k8s.io/autoscaler/cluster-autoscaler/core/scaleup/equivalence"
33
33
"k8s.io/autoscaler/cluster-autoscaler/core/scaleup/resource"
34
34
"k8s.io/autoscaler/cluster-autoscaler/core/utils"
35
- "k8s.io/autoscaler/cluster-autoscaler/estimator"
36
35
"k8s.io/autoscaler/cluster-autoscaler/expander"
37
36
"k8s.io/autoscaler/cluster-autoscaler/metrics"
38
37
ca_processors "k8s.io/autoscaler/cluster-autoscaler/processors"
@@ -363,7 +362,7 @@ func (o *ScaleUpOrchestrator) ScaleUpToNodeGroupMinSize(
363
362
continue
364
363
}
365
364
366
- if skipReason := o .IsNodeGroupResourceExceeded (resourcesLeft , ng , nodeInfo ); skipReason != nil {
365
+ if skipReason := o .IsNodeGroupResourceExceeded (resourcesLeft , ng , nodeInfo , 1 ); skipReason != nil {
367
366
klog .Warning ("ScaleUpToNodeGroupMinSize: node group resource excceded: %v" , skipReason )
368
367
continue
369
368
}
@@ -446,8 +445,10 @@ func (o *ScaleUpOrchestrator) filterValidScaleUpNodeGroups(
446
445
if err != nil {
447
446
klog .Errorf ("Couldn't get autoscaling options for ng: %v" , nodeGroup .Id ())
448
447
}
449
- if autoscalingOptions != nil && autoscalingOptions .AtomicScaleUp {
450
- if o .autoscalingContext .MaxNodesTotal != 0 && currentNodeCount + (nodeGroup .MaxSize ()- currentTargetSize ) > o .autoscalingContext .MaxNodesTotal {
448
+ numNodes := 1
449
+ if autoscalingOptions != nil && autoscalingOptions .AtomicScaling {
450
+ numNodes = nodeGroup .MaxSize () - currentTargetSize
451
+ if o .autoscalingContext .MaxNodesTotal != 0 && currentNodeCount + numNodes > o .autoscalingContext .MaxNodesTotal {
451
452
klog .V (4 ).Infof ("Skipping node group %s - atomic scale-up exceeds cluster node count limit" , nodeGroup .Id ())
452
453
skippedNodeGroups [nodeGroup .Id ()] = NewSkippedReasons ("atomic scale-up exceeds cluster node count limit" )
453
454
continue
@@ -460,7 +461,7 @@ func (o *ScaleUpOrchestrator) filterValidScaleUpNodeGroups(
460
461
skippedNodeGroups [nodeGroup .Id ()] = NotReadyReason
461
462
continue
462
463
}
463
- if skipReason := o .IsNodeGroupResourceExceeded (resourcesLeft , nodeGroup , nodeInfo ); skipReason != nil {
464
+ if skipReason := o .IsNodeGroupResourceExceeded (resourcesLeft , nodeGroup , nodeInfo , numNodes ); skipReason != nil {
464
465
skippedNodeGroups [nodeGroup .Id ()] = skipReason
465
466
continue
466
467
}
@@ -486,35 +487,19 @@ func (o *ScaleUpOrchestrator) ComputeExpansionOption(
486
487
return option
487
488
}
488
489
490
+ estimator := o .autoscalingContext .EstimatorBuilder (o .autoscalingContext .PredicateChecker , o .autoscalingContext .ClusterSnapshot )
491
+ option .NodeCount , option .Pods = estimator .Estimate (pods , nodeInfo , nodeGroup )
492
+ option .SimilarNodeGroups = o .ComputeSimilarNodeGroups (nodeGroup , nodeInfos , schedulablePods , now )
493
+
489
494
autoscalingOptions , err := nodeGroup .GetOptions (o .autoscalingContext .NodeGroupDefaults )
490
495
if err != nil {
491
496
klog .Errorf ("Failed to get autoscaling options for node group %s: %v" , nodeGroup .Id (), err )
492
497
}
493
- if autoscalingOptions != nil && autoscalingOptions .AtomicScaleUp {
494
- // If atomic, there should be no similar node groups for balancing
495
- // Also the number of pods should be capped according to the node count.
496
-
497
- // Limit the number of nodes we estimate to the max scale up possible.
498
- currentTargetSize , err := nodeGroup .TargetSize ()
499
- if err != nil {
500
- klog .Errorf ("Failed to get node group size: %v" , err )
501
- return option
502
- }
503
- // When the node group has the atomic scale up option, the number of nodes
504
- // that can be added to the node group should be capped according to the
505
- // maximum size of the node group and not the 'MaxNodesPerScaleUp' option.
506
- nodeEstimationCap := nodeGroup .MaxSize () - currentTargetSize
507
- limiter := estimator .NewThresholdBasedEstimationLimiter (nodeEstimationCap , 0 )
508
- estimator := estimator .NewBinpackingNodeEstimator (o .autoscalingContext .PredicateChecker , o .autoscalingContext .ClusterSnapshot , limiter , estimator .NewDecreasingPodOrderer ())
509
- option .NodeCount , option .Pods = estimator .Estimate (pods , nodeInfo , nodeGroup )
498
+ if autoscalingOptions != nil && autoscalingOptions .AtomicScaling {
510
499
if option .NodeCount > 0 && option .NodeCount != nodeGroup .MaxSize () {
511
500
option .NodeCount = nodeGroup .MaxSize ()
512
501
}
513
- return option
514
502
}
515
- estimator := o .autoscalingContext .EstimatorBuilder (o .autoscalingContext .PredicateChecker , o .autoscalingContext .ClusterSnapshot )
516
- option .NodeCount , option .Pods = estimator .Estimate (pods , nodeInfo , nodeGroup )
517
- option .SimilarNodeGroups = o .ComputeSimilarNodeGroups (nodeGroup , nodeInfos , schedulablePods , now )
518
503
return option
519
504
}
520
505
@@ -590,20 +575,15 @@ func (o *ScaleUpOrchestrator) IsNodeGroupReadyToScaleUp(nodeGroup cloudprovider.
590
575
}
591
576
592
577
// IsNodeGroupResourceExceeded returns nil if node group resource limits are not exceeded, otherwise a reason is provided.
593
- func (o * ScaleUpOrchestrator ) IsNodeGroupResourceExceeded (resourcesLeft resource.Limits , nodeGroup cloudprovider.NodeGroup , nodeInfo * schedulerframework.NodeInfo ) status.Reasons {
578
+ func (o * ScaleUpOrchestrator ) IsNodeGroupResourceExceeded (resourcesLeft resource.Limits , nodeGroup cloudprovider.NodeGroup , nodeInfo * schedulerframework.NodeInfo , numNodes int ) status.Reasons {
594
579
resourcesDelta , err := o .resourceManager .DeltaForNode (o .autoscalingContext , nodeInfo , nodeGroup )
595
580
if err != nil {
596
581
klog .Errorf ("Skipping node group %s; error getting node group resources: %v" , nodeGroup .Id (), err )
597
582
return NotReadyReason
598
583
}
599
- autoscalingOptions , aErr := nodeGroup .GetOptions (o .autoscalingContext .NodeGroupDefaults )
600
- if aErr != nil {
601
- klog .Errorf ("Couldn't get autoscaling options for ng: %v" , nodeGroup .Id ())
602
- }
603
- if autoscalingOptions != nil && autoscalingOptions .AtomicScaleUp {
604
- for resource , delta := range resourcesDelta {
605
- resourcesDelta [resource ] = delta * int64 (nodeGroup .MaxSize ())
606
- }
584
+
585
+ for resource , delta := range resourcesDelta {
586
+ resourcesDelta [resource ] = delta * int64 (numNodes )
607
587
}
608
588
609
589
checkResult := resource .CheckDeltaWithinLimits (resourcesLeft , resourcesDelta )
@@ -649,6 +629,14 @@ func (o *ScaleUpOrchestrator) ComputeSimilarNodeGroups(
649
629
return nil
650
630
}
651
631
632
+ autoscalingOptions , err := nodeGroup .GetOptions (o .autoscalingContext .NodeGroupDefaults )
633
+ if err != nil {
634
+ klog .Errorf ("Failed to get autoscaling options for node group %s: %v" , nodeGroup .Id (), err )
635
+ }
636
+ if autoscalingOptions != nil && autoscalingOptions .AtomicScaling {
637
+ return nil
638
+ }
639
+
652
640
groupSchedulablePods , found := schedulablePods [nodeGroup .Id ()]
653
641
if ! found || len (groupSchedulablePods ) == 0 {
654
642
return nil
0 commit comments