cluster-autoscaler: avoid goto in filterNodeGroupsByPods
This commit is contained in:
parent
226784a223
commit
87dba05278
|
|
@ -664,26 +664,29 @@ func filterNodeGroupsByPods(
|
||||||
|
|
||||||
result := make([]cloudprovider.NodeGroup, 0)
|
result := make([]cloudprovider.NodeGroup, 0)
|
||||||
|
|
||||||
groupsloop:
|
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
option, found := expansionOptions[group.Id()]
|
option, found := expansionOptions[group.Id()]
|
||||||
if !found {
|
if !found {
|
||||||
klog.V(1).Infof("No info about pods passing predicates found for group %v, skipping it from scale-up consideration", group.Id())
|
klog.V(1).Infof("No info about pods passing predicates found for group %v, skipping it from scale-up consideration", group.Id())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fittingPods := option.Pods
|
fittingPods := make(map[*apiv1.Pod]bool, len(option.Pods))
|
||||||
podSet := make(map[*apiv1.Pod]bool, len(fittingPods))
|
for _, pod := range option.Pods {
|
||||||
for _, pod := range fittingPods {
|
fittingPods[pod] = true
|
||||||
podSet[pod] = true
|
|
||||||
}
|
}
|
||||||
|
allFit := true
|
||||||
for _, pod := range podsRequiredToFit {
|
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)
|
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
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue