Skip to content

Commit 87dba05

Browse files
committed
cluster-autoscaler: avoid goto in filterNodeGroupsByPods
1 parent 226784a commit 87dba05

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

cluster-autoscaler/core/scale_up.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -664,26 +664,29 @@ func filterNodeGroupsByPods(
664664

665665
result := make([]cloudprovider.NodeGroup, 0)
666666

667-
groupsloop:
668667
for _, group := range groups {
669668
option, found := expansionOptions[group.Id()]
670669
if !found {
671670
klog.V(1).Infof("No info about pods passing predicates found for group %v, skipping it from scale-up consideration", group.Id())
672671
continue
673672
}
674-
fittingPods := option.Pods
675-
podSet := make(map[*apiv1.Pod]bool, len(fittingPods))
676-
for _, pod := range fittingPods {
677-
podSet[pod] = true
673+
fittingPods := make(map[*apiv1.Pod]bool, len(option.Pods))
674+
for _, pod := range option.Pods {
675+
fittingPods[pod] = true
678676
}
677+
allFit := true
679678
for _, pod := range podsRequiredToFit {
680-
if _, found := podSet[pod]; !found {
679+
if _, found := fittingPods[pod]; !found {
681680
klog.V(1).Infof("Group %v, can't fit pod %v/%v, removing from scale-up consideration", group.Id(), pod.Namespace, pod.Name)
682-
continue groupsloop
681+
allFit = false
682+
break
683683
}
684684
}
685-
result = append(result, group)
685+
if allFit {
686+
result = append(result, group)
687+
}
686688
}
689+
687690
return result
688691
}
689692

0 commit comments

Comments
 (0)