Skip to content

Commit 6992977

Browse files
authored
Merge pull request #1164 from a7i/podlifetime-CrashLoopBackOff
PodLifeTime: support CrashLoopBackOff container state
2 parents 877d9b1 + 1b97652 commit 6992977

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pkg/framework/plugins/podlifetime/validation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error {
4444
}
4545
}
4646
podLifeTimeAllowedStates := sets.New(
47+
// Pod phase reasons
4748
string(v1.PodRunning),
4849
string(v1.PodPending),
4950

50-
// Container state reasons: https://github.com/kubernetes/kubernetes/blob/release-1.24/pkg/kubelet/kubelet_pods.go#L76-L79
51+
// Container state reasons
5152
"PodInitializing",
5253
"ContainerCreating",
54+
"CrashLoopBackOff",
5355
)
5456

5557
if !podLifeTimeAllowedStates.HasAll(args.States...) {

pkg/framework/plugins/podlifetime/validation_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"testing"
2121

2222
v1 "k8s.io/api/core/v1"
23+
utilpointer "k8s.io/utils/pointer"
2324
)
2425

2526
func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
@@ -31,7 +32,7 @@ func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
3132
{
3233
description: "valid arg, no errors",
3334
args: &PodLifeTimeArgs{
34-
MaxPodLifeTimeSeconds: func(i uint) *uint { return &i }(1),
35+
MaxPodLifeTimeSeconds: utilpointer.Uint(1),
3536
States: []string{string(v1.PodRunning)},
3637
},
3738
expectError: false,
@@ -50,6 +51,14 @@ func TestValidateRemovePodLifeTimeArgs(t *testing.T) {
5051
},
5152
expectError: true,
5253
},
54+
{
55+
description: "allows CrashLoopBackOff state",
56+
args: &PodLifeTimeArgs{
57+
MaxPodLifeTimeSeconds: utilpointer.Uint(1),
58+
States: []string{"CrashLoopBackOff"},
59+
},
60+
expectError: false,
61+
},
5362
}
5463

5564
for _, tc := range testCases {

0 commit comments

Comments
 (0)