Skip to content

Commit e3552bb

Browse files
authored
Merge pull request kubernetes#5084 from grosser/grosser/ref
cluster-autoscaler: avoid goto in filterNodeGroupsByPods
2 parents 5d3ad0c + 87dba05 commit e3552bb

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
@@ -670,26 +670,29 @@ func filterNodeGroupsByPods(
670670

671671
result := make([]cloudprovider.NodeGroup, 0)
672672

673-
groupsloop:
674673
for _, group := range groups {
675674
option, found := expansionOptions[group.Id()]
676675
if !found {
677676
klog.V(1).Infof("No info about pods passing predicates found for group %v, skipping it from scale-up consideration", group.Id())
678677
continue
679678
}
680-
fittingPods := option.Pods
681-
podSet := make(map[*apiv1.Pod]bool, len(fittingPods))
682-
for _, pod := range fittingPods {
683-
podSet[pod] = true
679+
fittingPods := make(map[*apiv1.Pod]bool, len(option.Pods))
680+
for _, pod := range option.Pods {
681+
fittingPods[pod] = true
684682
}
683+
allFit := true
685684
for _, pod := range podsRequiredToFit {
686-
if _, found := podSet[pod]; !found {
685+
if _, found := fittingPods[pod]; !found {
687686
klog.V(1).Infof("Group %v, can't fit pod %v/%v, removing from scale-up consideration", group.Id(), pod.Namespace, pod.Name)
688-
continue groupsloop
687+
allFit = false
688+
break
689689
}
690690
}
691-
result = append(result, group)
691+
if allFit {
692+
result = append(result, group)
693+
}
692694
}
695+
693696
return result
694697
}
695698

0 commit comments

Comments
 (0)