estimate some system daemonset overhead for max pods

This commit is contained in:
Benjamin Elder 2025-04-08 14:46:06 -07:00
parent 92af6ab692
commit b2933c0ada

View File

@ -59,18 +59,23 @@ func estimateMaximumPods(ctx context.Context, c clientset.Interface, min, max in
framework.ExpectNoError(err) framework.ExpectNoError(err)
availablePods := int32(0) availablePods := int32(0)
// estimate some reasonable overhead per-node for pods that are non-test
const daemonSetReservedPods = 10
for _, node := range nodes.Items { for _, node := range nodes.Items {
if q, ok := node.Status.Allocatable["pods"]; ok { if q, ok := node.Status.Allocatable["pods"]; ok {
if num, ok := q.AsInt64(); ok { if num, ok := q.AsInt64(); ok {
availablePods += int32(num) if num > daemonSetReservedPods {
availablePods += int32(num - daemonSetReservedPods)
}
continue continue
} }
} }
// best guess per node, since default maxPerCore is 10 and most nodes have at least // Only when we fail to obtain the number, we fall back to a best guess
// per node. Since default maxPerCore is 10 and most nodes have at least
// one core. // one core.
availablePods += 10 availablePods += 10
} }
//avoid creating exactly max pods // avoid creating exactly max pods
availablePods = int32(float32(availablePods) * 0.5) availablePods = int32(float32(availablePods) * 0.5)
// bound the top and bottom // bound the top and bottom
if availablePods > max { if availablePods > max {