mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 05:14:13 +01:00
refactor(TestPodLifeTime): drop applyPodsFunc function
This commit is contained in:
@@ -81,7 +81,6 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
maxPodsToEvictPerNode *uint
|
maxPodsToEvictPerNode *uint
|
||||||
maxPodsToEvictPerNamespace *uint
|
maxPodsToEvictPerNamespace *uint
|
||||||
maxPodsToEvictTotal *uint
|
maxPodsToEvictTotal *uint
|
||||||
applyPodsFunc func(pods []*v1.Pod)
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
description: "Two pods in the default namespace, 1 is new and 1 very is old. 1 should be evicted.",
|
description: "Two pods in the default namespace, 1 is new and 1 very is old. 1 should be evicted.",
|
||||||
@@ -334,19 +333,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"ImagePullBackOff"},
|
States: []string{"ImagePullBackOff"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.ContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "ImagePullBackOff"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.ContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "ImagePullBackOff"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with container status CrashLoopBackOff should be evicted",
|
description: "1 pod with container status CrashLoopBackOff should be evicted",
|
||||||
@@ -355,19 +353,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"CrashLoopBackOff"},
|
States: []string{"CrashLoopBackOff"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.ContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "CrashLoopBackOff"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.ContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "CrashLoopBackOff"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with container status CreateContainerConfigError should be evicted",
|
description: "1 pod with container status CreateContainerConfigError should be evicted",
|
||||||
@@ -376,19 +373,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"CreateContainerConfigError"},
|
States: []string{"CreateContainerConfigError"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.ContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerConfigError"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.ContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerConfigError"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with container status ErrImagePull should be evicted",
|
description: "1 pod with container status ErrImagePull should be evicted",
|
||||||
@@ -397,19 +393,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"ErrImagePull"},
|
States: []string{"ErrImagePull"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.ContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "ErrImagePull"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.ContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "ErrImagePull"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with init container status CreateContainerError should not be evicted without includingInitContainers",
|
description: "1 pod with init container status CreateContainerError should not be evicted without includingInitContainers",
|
||||||
@@ -418,19 +413,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"CreateContainerError"},
|
States: []string{"CreateContainerError"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.InitContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 0,
|
expectedEvictedPodCount: 0,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.InitContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with init container status CreateContainerError should be evicted with includingInitContainers",
|
description: "1 pod with init container status CreateContainerError should be evicted with includingInitContainers",
|
||||||
@@ -440,19 +434,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
IncludingInitContainers: true,
|
IncludingInitContainers: true,
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.InitContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.InitContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with ephemeral container status CreateContainerError should not be evicted without includingEphemeralContainers",
|
description: "1 pod with ephemeral container status CreateContainerError should not be evicted without includingEphemeralContainers",
|
||||||
@@ -461,19 +454,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"CreateContainerError"},
|
States: []string{"CreateContainerError"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.InitContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 0,
|
expectedEvictedPodCount: 0,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.InitContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with ephemeral container status CreateContainerError should be evicted with includingEphemeralContainers",
|
description: "1 pod with ephemeral container status CreateContainerError should be evicted with includingEphemeralContainers",
|
||||||
@@ -483,19 +475,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
IncludingEphemeralContainers: true,
|
IncludingEphemeralContainers: true,
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.EphemeralContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.EphemeralContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with container status CreateContainerError should be evicted",
|
description: "1 pod with container status CreateContainerError should be evicted",
|
||||||
@@ -504,19 +495,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"CreateContainerError"},
|
States: []string{"CreateContainerError"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.ContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.ContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "CreateContainerError"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with container status InvalidImageName should be evicted",
|
description: "1 pod with container status InvalidImageName should be evicted",
|
||||||
@@ -525,19 +515,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"InvalidImageName"},
|
States: []string{"InvalidImageName"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.ContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "InvalidImageName"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.ContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "InvalidImageName"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with pod status reason NodeLost should be evicted",
|
description: "1 pod with pod status reason NodeLost should be evicted",
|
||||||
@@ -546,13 +535,12 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"NodeLost"},
|
States: []string{"NodeLost"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.Reason = "NodeLost"
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.Reason = "NodeLost"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with pod status reason NodeAffinity should be evicted",
|
description: "1 pod with pod status reason NodeAffinity should be evicted",
|
||||||
@@ -561,13 +549,12 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"NodeAffinity"},
|
States: []string{"NodeAffinity"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.Reason = "NodeAffinity"
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.Reason = "NodeAffinity"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with pod status reason Shutdown should be evicted",
|
description: "1 pod with pod status reason Shutdown should be evicted",
|
||||||
@@ -576,13 +563,12 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"Shutdown"},
|
States: []string{"Shutdown"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.Reason = "Shutdown"
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.Reason = "Shutdown"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with pod status reason UnexpectedAdmissionError should be evicted",
|
description: "1 pod with pod status reason UnexpectedAdmissionError should be evicted",
|
||||||
@@ -591,13 +577,12 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"UnexpectedAdmissionError"},
|
States: []string{"UnexpectedAdmissionError"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.Reason = "UnexpectedAdmissionError"
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.Reason = "UnexpectedAdmissionError"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with pod status phase v1.PodSucceeded should be evicted",
|
description: "1 pod with pod status phase v1.PodSucceeded should be evicted",
|
||||||
@@ -607,14 +592,11 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefForNode1("p16", olderPodCreationTime, func(pod *v1.Pod) {
|
buildTestPodWithRSOwnerRefForNode1("p16", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
pod.Status.Phase = v1.PodUnknown
|
pod.Status.Phase = v1.PodSucceeded
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.Phase = v1.PodSucceeded
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with pod status phase v1.PodUnknown should be evicted",
|
description: "1 pod with pod status phase v1.PodUnknown should be evicted",
|
||||||
@@ -624,14 +606,11 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefForNode1("p16", olderPodCreationTime, func(pod *v1.Pod) {
|
buildTestPodWithRSOwnerRefForNode1("p16", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
pod.Status.Phase = v1.PodUnknown
|
pod.Status.Phase = v1.PodFailed
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.Phase = v1.PodFailed
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod with pod status phase v1.PodUnknown should be evicted",
|
description: "1 pod with pod status phase v1.PodUnknown should be evicted",
|
||||||
@@ -646,9 +625,6 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 1,
|
expectedEvictedPodCount: 1,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.Phase = v1.PodUnknown
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "1 pod without ImagePullBackOff States should be ignored",
|
description: "1 pod without ImagePullBackOff States should be ignored",
|
||||||
@@ -657,19 +633,18 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
States: []string{"ContainerCreating"},
|
States: []string{"ContainerCreating"},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, nil),
|
buildTestPodWithRSOwnerRefWithPendingPhaseForNode1("p9", olderPodCreationTime, func(pod *v1.Pod) {
|
||||||
|
pod.Status.ContainerStatuses = []v1.ContainerStatus{
|
||||||
|
{
|
||||||
|
State: v1.ContainerState{
|
||||||
|
Waiting: &v1.ContainerStateWaiting{Reason: "ImagePullBackOff"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
nodes: []*v1.Node{buildTestNode1()},
|
nodes: []*v1.Node{buildTestNode1()},
|
||||||
expectedEvictedPodCount: 0,
|
expectedEvictedPodCount: 0,
|
||||||
applyPodsFunc: func(pods []*v1.Pod) {
|
|
||||||
pods[0].Status.ContainerStatuses = []v1.ContainerStatus{
|
|
||||||
{
|
|
||||||
State: v1.ContainerState{
|
|
||||||
Waiting: &v1.ContainerStateWaiting{Reason: "ImagePullBackOff"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,10 +653,6 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
if tc.applyPodsFunc != nil {
|
|
||||||
tc.applyPodsFunc(tc.pods)
|
|
||||||
}
|
|
||||||
|
|
||||||
var objs []runtime.Object
|
var objs []runtime.Object
|
||||||
for _, node := range tc.nodes {
|
for _, node := range tc.nodes {
|
||||||
objs = append(objs, node)
|
objs = append(objs, node)
|
||||||
|
|||||||
Reference in New Issue
Block a user