@@ -417,10 +417,6 @@ func (sd *ScaleDown) UpdateUnneededNodes(
417417 // This should never happen, List() returns err only because scheduler interface requires it.
418418 return errors .ToAutoscalerError (errors .InternalError , err )
419419 }
420- destinations := make (map [string ]bool , len (destinationNodes ))
421- for _ , destination := range destinationNodes {
422- destinations [destination .Name ] = true
423- }
424420
425421 sd .updateUnremovableNodes ()
426422
@@ -500,6 +496,11 @@ func (sd *ScaleDown) UpdateUnneededNodes(
500496 // Phase2 - check which nodes can be probably removed using fast drain.
501497 currentCandidates , currentNonCandidates := sd .chooseCandidates (currentlyUnneededNonEmptyNodes )
502498
499+ destinations := make ([]string , 0 , len (destinationNodes ))
500+ for _ , destinationNode := range destinationNodes {
501+ destinations = append (destinations , destinationNode .Name )
502+ }
503+
503504 // Look for nodes to remove in the current candidates
504505 nodesToRemove , unremovable , newHints , simulatorErr := simulator .FindNodesToRemove (
505506 currentCandidates ,
@@ -751,7 +752,7 @@ func (sd *ScaleDown) TryToScaleDown(pdbs []*policyv1.PodDisruptionBudget, curren
751752 }
752753
753754 nodesWithoutMaster := filterOutMasters (allNodeInfos )
754- nodesWithoutMasterNames := make (map [ string ] bool , len (nodesWithoutMaster ))
755+ nodesWithoutMasterNames := make ([] string , 0 , len (nodesWithoutMaster ))
755756
756757 candidateNames := make ([]string , 0 )
757758 readinessMap := make (map [string ]bool )
@@ -771,7 +772,7 @@ func (sd *ScaleDown) TryToScaleDown(pdbs []*policyv1.PodDisruptionBudget, curren
771772 resourcesWithLimits := resourceLimiter .GetResources ()
772773 for _ , nodeInfo := range nodesWithoutMaster {
773774 node := nodeInfo .Node ()
774- nodesWithoutMasterNames [ node . Name ] = true
775+ nodesWithoutMasterNames = append ( nodesWithoutMasterNames , node . Name )
775776
776777 unneededSince , found := sd .unneededNodes [node .Name ]
777778 if ! found {
0 commit comments