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

*1677 Allow Succeeded and Failed states in PodLifeTime

This commit is contained in:
Martin Tapp
2025-05-23 13:13:01 -04:00
parent 9f918371a2
commit e06443ef40
4 changed files with 39 additions and 1 deletions

View File

@@ -577,6 +577,32 @@ func TestPodLifeTime(t *testing.T) {
pods[0].Status.Reason = "UnexpectedAdmissionError"
},
},
{
description: "1 pod with pod status phase v1.PodSucceeded should be evicted",
args: &PodLifeTimeArgs{
MaxPodLifeTimeSeconds: &maxLifeTime,
States: []string{string(v1.PodSucceeded)},
},
pods: []*v1.Pod{p16},
nodes: []*v1.Node{node1},
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",
args: &PodLifeTimeArgs{
MaxPodLifeTimeSeconds: &maxLifeTime,
States: []string{string(v1.PodFailed)},
},
pods: []*v1.Pod{p16},
nodes: []*v1.Node{node1},
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",
args: &PodLifeTimeArgs{

View File

@@ -47,6 +47,8 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error {
// Pod Status Phase
string(v1.PodRunning),
string(v1.PodPending),
string(v1.PodSucceeded),
string(v1.PodFailed),
string(v1.PodUnknown),
// Pod Status Reasons

View File

@@ -36,6 +36,14 @@ func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
},
expectError: false,
},
{
description: "Pod Status Reasons Succeeded or Failed",
args: &PodLifeTimeArgs{
MaxPodLifeTimeSeconds: func(i uint) *uint { return &i }(1),
States: []string{string(v1.PodSucceeded), string(v1.PodFailed)},
},
expectError: false,
},
{
description: "Pod Status Reasons CrashLoopBackOff ",
args: &PodLifeTimeArgs{