Skip to content

Commit

Permalink
Merge pull request #1164 from a7i/podlifetime-CrashLoopBackOff
Browse files Browse the repository at this point in the history
PodLifeTime: support CrashLoopBackOff container state
  • Loading branch information
k8s-ci-robot authored Jun 7, 2023
2 parents 877d9b1 + 1b97652 commit 6992977
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/framework/plugins/podlifetime/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error {
}
}
podLifeTimeAllowedStates := sets.New(
// Pod phase reasons
string(v1.PodRunning),
string(v1.PodPending),

// Container state reasons: https://github.com/kubernetes/kubernetes/blob/release-1.24/pkg/kubelet/kubelet_pods.go#L76-L79
// Container state reasons
"PodInitializing",
"ContainerCreating",
"CrashLoopBackOff",
)

if !podLifeTimeAllowedStates.HasAll(args.States...) {
Expand Down
11 changes: 10 additions & 1 deletion pkg/framework/plugins/podlifetime/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

v1 "k8s.io/api/core/v1"
utilpointer "k8s.io/utils/pointer"
)

func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
Expand All @@ -31,7 +32,7 @@ func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
{
description: "valid arg, no errors",
args: &PodLifeTimeArgs{
MaxPodLifeTimeSeconds: func(i uint) *uint { return &i }(1),
MaxPodLifeTimeSeconds: utilpointer.Uint(1),
States: []string{string(v1.PodRunning)},
},
expectError: false,
Expand All @@ -50,6 +51,14 @@ func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
},
expectError: true,
},
{
description: "allows CrashLoopBackOff state",
args: &PodLifeTimeArgs{
MaxPodLifeTimeSeconds: utilpointer.Uint(1),
States: []string{"CrashLoopBackOff"},
},
expectError: false,
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 6992977

Please sign in to comment.