Skip to content

Commit

Permalink
Merge pull request kubernetes#5084 from grosser/grosser/ref
Browse files Browse the repository at this point in the history
cluster-autoscaler: avoid goto in filterNodeGroupsByPods
  • Loading branch information
k8s-ci-robot authored Aug 18, 2022
2 parents 5d3ad0c + 87dba05 commit e3552bb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cluster-autoscaler/core/scale_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,26 +670,29 @@ func filterNodeGroupsByPods(

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

groupsloop:
for _, group := range groups {
option, found := expansionOptions[group.Id()]
if !found {
klog.V(1).Infof("No info about pods passing predicates found for group %v, skipping it from scale-up consideration", group.Id())
continue
}
fittingPods := option.Pods
podSet := make(map[*apiv1.Pod]bool, len(fittingPods))
for _, pod := range fittingPods {
podSet[pod] = true
fittingPods := make(map[*apiv1.Pod]bool, len(option.Pods))
for _, pod := range option.Pods {
fittingPods[pod] = true
}
allFit := true
for _, pod := range podsRequiredToFit {
if _, found := podSet[pod]; !found {
if _, found := fittingPods[pod]; !found {
klog.V(1).Infof("Group %v, can't fit pod %v/%v, removing from scale-up consideration", group.Id(), pod.Namespace, pod.Name)
continue groupsloop
allFit = false
break
}
}
result = append(result, group)
if allFit {
result = append(result, group)
}
}

return result
}

Expand Down

0 comments on commit e3552bb

Please sign in to comment.