mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 14:41:10 +01:00
Merge pull request #1696 from doctapp/PodLifeTimeAllStates
*1677 Allow Succeeded and Failed states in PodLifeTime
This commit is contained in:
@@ -727,7 +727,9 @@ profiles:
|
|||||||
This strategy evicts pods that are older than `maxPodLifeTimeSeconds`.
|
This strategy evicts pods that are older than `maxPodLifeTimeSeconds`.
|
||||||
|
|
||||||
You can also specify `states` parameter to **only** evict pods matching the following conditions:
|
You can also specify `states` parameter to **only** evict pods matching the following conditions:
|
||||||
- [Pod Phase](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase) status of: `Running`, `Pending`, `Unknown`
|
> The primary purpose for using states like `Succeeded` and `Failed` is releasing resources so that new pods can be rescheduled.
|
||||||
|
> I.e., the main motivation is not for cleaning pods, rather to release resources.
|
||||||
|
- [Pod Phase](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase) status of: `Running`, `Pending`, `Succeeded`, `Failed`, `Unknown`
|
||||||
- [Pod Reason](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions) reasons of: `NodeAffinity`, `NodeLost`, `Shutdown`, `UnexpectedAdmissionError`
|
- [Pod Reason](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-conditions) reasons of: `NodeAffinity`, `NodeLost`, `Shutdown`, `UnexpectedAdmissionError`
|
||||||
- [Container State Waiting](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-state-waiting) condition of: `PodInitializing`, `ContainerCreating`, `ImagePullBackOff`, `CrashLoopBackOff`, `CreateContainerConfigError`, `ErrImagePull`, `ImagePullBackOff`, `CreateContainerError`, `InvalidImageName`
|
- [Container State Waiting](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-state-waiting) condition of: `PodInitializing`, `ContainerCreating`, `ImagePullBackOff`, `CrashLoopBackOff`, `CreateContainerConfigError`, `ErrImagePull`, `ImagePullBackOff`, `CreateContainerError`, `InvalidImageName`
|
||||||
|
|
||||||
|
|||||||
@@ -577,6 +577,32 @@ func TestPodLifeTime(t *testing.T) {
|
|||||||
pods[0].Status.Reason = "UnexpectedAdmissionError"
|
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",
|
description: "1 pod with pod status phase v1.PodUnknown should be evicted",
|
||||||
args: &PodLifeTimeArgs{
|
args: &PodLifeTimeArgs{
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error {
|
|||||||
// Pod Status Phase
|
// Pod Status Phase
|
||||||
string(v1.PodRunning),
|
string(v1.PodRunning),
|
||||||
string(v1.PodPending),
|
string(v1.PodPending),
|
||||||
|
string(v1.PodSucceeded),
|
||||||
|
string(v1.PodFailed),
|
||||||
string(v1.PodUnknown),
|
string(v1.PodUnknown),
|
||||||
|
|
||||||
// Pod Status Reasons
|
// Pod Status Reasons
|
||||||
|
|||||||
@@ -36,6 +36,14 @@ func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectError: false,
|
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 ",
|
description: "Pod Status Reasons CrashLoopBackOff ",
|
||||||
args: &PodLifeTimeArgs{
|
args: &PodLifeTimeArgs{
|
||||||
|
|||||||
Reference in New Issue
Block a user