diff --git a/cluster-autoscaler/core/scaleup/orchestrator/async_initializer.go b/cluster-autoscaler/core/scaleup/orchestrator/async_initializer.go index 0a681fd5a903..92e6a5235abc 100644 --- a/cluster-autoscaler/core/scaleup/orchestrator/async_initializer.go +++ b/cluster-autoscaler/core/scaleup/orchestrator/async_initializer.go @@ -50,7 +50,8 @@ type AsyncNodeGroupInitializer struct { atomicScaleUp bool } -func newAsyncNodeGroupInitializer( +// NewAsyncNodeGroupInitializer creates a new AsyncNodeGroupInitializer instance. +func NewAsyncNodeGroupInitializer( nodeGroup cloudprovider.NodeGroup, nodeInfo *framework.NodeInfo, scaleUpExecutor *scaleUpExecutor, diff --git a/cluster-autoscaler/core/scaleup/orchestrator/executor.go b/cluster-autoscaler/core/scaleup/orchestrator/executor.go index 5c835e5d384d..150d101a077a 100644 --- a/cluster-autoscaler/core/scaleup/orchestrator/executor.go +++ b/cluster-autoscaler/core/scaleup/orchestrator/executor.go @@ -138,7 +138,7 @@ func (e *scaleUpExecutor) executeScaleUpsParallel( failedNodeGroups[i] = result.info.Group scaleUpErrors[i] = result.err } - return combineConcurrentScaleUpErrors(scaleUpErrors), failedNodeGroups + return CombineConcurrentScaleUpErrors(scaleUpErrors), failedNodeGroups } return nil, nil } @@ -188,7 +188,8 @@ func (e *scaleUpExecutor) executeScaleUp( return nil } -func combineConcurrentScaleUpErrors(errs []errors.AutoscalerError) errors.AutoscalerError { +// CombineConcurrentScaleUpErrors returns combined scale-up error to report after multiple concurrent scale-ups might haver failed. +func CombineConcurrentScaleUpErrors(errs []errors.AutoscalerError) errors.AutoscalerError { if len(errs) == 0 { return nil } diff --git a/cluster-autoscaler/core/scaleup/orchestrator/executor_test.go b/cluster-autoscaler/core/scaleup/orchestrator/executor_test.go index a7ef5d60f575..95428a4d205b 100644 --- a/cluster-autoscaler/core/scaleup/orchestrator/executor_test.go +++ b/cluster-autoscaler/core/scaleup/orchestrator/executor_test.go @@ -120,7 +120,7 @@ func TestCombinedConcurrentScaleUpErrors(t *testing.T) { for _, testCase := range testCases { t.Run(testCase.desc, func(t *testing.T) { - combinedErr := combineConcurrentScaleUpErrors(testCase.errors) + combinedErr := CombineConcurrentScaleUpErrors(testCase.errors) assert.Equal(t, testCase.expectedErr, combinedErr) }) } diff --git a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go index d57c2a6299b3..2ad6b989ab25 100644 --- a/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go +++ b/cluster-autoscaler/core/scaleup/orchestrator/orchestrator.go @@ -222,7 +222,9 @@ func (o *ScaleUpOrchestrator) ScaleUp( return buildNoOptionsAvailableStatus(markedEquivalenceGroups, skippedNodeGroups, nodeGroups), nil } var scaleUpStatus *status.ScaleUpStatus - createNodeGroupResults, scaleUpStatus, aErr = o.CreateNodeGroup(bestOption, nodeInfos, schedulablePodGroups, podEquivalenceGroups, daemonSets, allOrNothing) + oldId := bestOption.NodeGroup.Id() + initializer := NewAsyncNodeGroupInitializer(bestOption.NodeGroup, nodeInfos[oldId], o.scaleUpExecutor, o.taintConfig, daemonSets, o.processors.ScaleUpStatusProcessor, o.autoscalingContext, allOrNothing) + createNodeGroupResults, scaleUpStatus, aErr = o.CreateNodeGroup(bestOption, nodeInfos, schedulablePodGroups, podEquivalenceGroups, daemonSets, initializer) if aErr != nil { return scaleUpStatus, aErr } @@ -501,7 +503,7 @@ func (o *ScaleUpOrchestrator) CreateNodeGroup( schedulablePodGroups map[string][]estimator.PodEquivalenceGroup, podEquivalenceGroups []*equivalence.PodGroup, daemonSets []*appsv1.DaemonSet, - allOrNothing bool, + initializer nodegroups.AsyncNodeGroupInitializer, ) ([]nodegroups.CreateNodeGroupResult, *status.ScaleUpStatus, errors.AutoscalerError) { createNodeGroupResults := make([]nodegroups.CreateNodeGroupResult, 0) @@ -509,7 +511,6 @@ func (o *ScaleUpOrchestrator) CreateNodeGroup( var createNodeGroupResult nodegroups.CreateNodeGroupResult var aErr errors.AutoscalerError if o.autoscalingContext.AsyncNodeGroupsEnabled { - initializer := newAsyncNodeGroupInitializer(initialOption.NodeGroup, nodeInfos[oldId], o.scaleUpExecutor, o.taintConfig, daemonSets, o.processors.ScaleUpStatusProcessor, o.autoscalingContext, allOrNothing) createNodeGroupResult, aErr = o.processors.NodeGroupManager.CreateNodeGroupAsync(o.autoscalingContext, initialOption.NodeGroup, initializer) } else { createNodeGroupResult, aErr = o.processors.NodeGroupManager.CreateNodeGroup(o.autoscalingContext, initialOption.NodeGroup)