1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

refactor(TestRemovePodsHavingTooManyRestarts): extract setPodContainerStatusRestartCount helper

This commit is contained in:
Jan Chaloupka
2025-12-15 00:23:03 +01:00
parent bb01360776
commit 6ebb0b7aa7

View File

@@ -33,6 +33,24 @@ import (
"sigs.k8s.io/descheduler/test"
)
func setPodContainerStatusRestartCount(pod *v1.Pod, base int32) {
pod.Status = v1.PodStatus{
InitContainerStatuses: []v1.ContainerStatus{
{
RestartCount: 5 * base,
},
},
ContainerStatuses: []v1.ContainerStatus{
{
RestartCount: 10 * base,
},
{
RestartCount: 10 * base,
},
},
}
}
func initPods(node *v1.Node) []*v1.Pod {
pods := make([]*v1.Pod, 0)
@@ -41,21 +59,7 @@ func initPods(node *v1.Node) []*v1.Pod {
pod.ObjectMeta.OwnerReferences = test.GetNormalPodOwnerRefList()
// pod at index i will have 25 * i restarts.
pod.Status = v1.PodStatus{
InitContainerStatuses: []v1.ContainerStatus{
{
RestartCount: 5 * i,
},
},
ContainerStatuses: []v1.ContainerStatus{
{
RestartCount: 10 * i,
},
{
RestartCount: 10 * i,
},
},
}
setPodContainerStatusRestartCount(pod, i)
pods = append(pods, pod)
}