Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2546557

Browse files
authoredMar 20, 2025
Merge pull request kubernetes#130621 from sreeram-venkitesh/4818-sleep-action-zero-value-beta-graduation
KEP 4818: PodLifecycleSleepActionAllowZero to Beta
2 parents 48ba25a + 323d55e commit 2546557

File tree

3 files changed

+96
-5
lines changed

3 files changed

+96
-5
lines changed
 

‎pkg/api/pod/util_test.go

+91-5
Original file line numberDiff line numberDiff line change
@@ -4114,12 +4114,14 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
41144114
testCases := []struct {
41154115
name string
41164116
podSpec *api.PodSpec
4117+
featureEnabled bool
41174118
expectAllowPodLifecycleSleepActionZeroValue bool
41184119
}{
41194120
{
4120-
name: "no lifecycle hooks",
4121-
podSpec: &api.PodSpec{},
4122-
expectAllowPodLifecycleSleepActionZeroValue: false,
4121+
name: "no lifecycle hooks",
4122+
podSpec: &api.PodSpec{},
4123+
featureEnabled: true,
4124+
expectAllowPodLifecycleSleepActionZeroValue: true,
41234125
},
41244126
{
41254127
name: "Prestop with non-zero second duration",
@@ -4136,7 +4138,8 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
41364138
},
41374139
},
41384140
},
4139-
expectAllowPodLifecycleSleepActionZeroValue: false,
4141+
featureEnabled: true,
4142+
expectAllowPodLifecycleSleepActionZeroValue: true,
41404143
},
41414144
{
41424145
name: "PostStart with non-zero second duration",
@@ -4153,7 +4156,8 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
41534156
},
41544157
},
41554158
},
4156-
expectAllowPodLifecycleSleepActionZeroValue: false,
4159+
featureEnabled: true,
4160+
expectAllowPodLifecycleSleepActionZeroValue: true,
41574161
},
41584162
{
41594163
name: "PreStop with zero seconds",
@@ -4170,6 +4174,7 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
41704174
},
41714175
},
41724176
},
4177+
featureEnabled: true,
41734178
expectAllowPodLifecycleSleepActionZeroValue: true,
41744179
},
41754180
{
@@ -4187,12 +4192,93 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
41874192
},
41884193
},
41894194
},
4195+
featureEnabled: true,
4196+
expectAllowPodLifecycleSleepActionZeroValue: true,
4197+
},
4198+
{
4199+
name: "no lifecycle hooks with feature gate disabled",
4200+
podSpec: &api.PodSpec{},
4201+
featureEnabled: false,
4202+
expectAllowPodLifecycleSleepActionZeroValue: false,
4203+
},
4204+
{
4205+
name: "Prestop with non-zero second duration with feature gate disabled",
4206+
podSpec: &api.PodSpec{
4207+
Containers: []api.Container{
4208+
{
4209+
Lifecycle: &api.Lifecycle{
4210+
PreStop: &api.LifecycleHandler{
4211+
Sleep: &api.SleepAction{
4212+
Seconds: 1,
4213+
},
4214+
},
4215+
},
4216+
},
4217+
},
4218+
},
4219+
featureEnabled: false,
4220+
expectAllowPodLifecycleSleepActionZeroValue: false,
4221+
},
4222+
{
4223+
name: "PostStart with non-zero second duration with feature gate disabled",
4224+
podSpec: &api.PodSpec{
4225+
Containers: []api.Container{
4226+
{
4227+
Lifecycle: &api.Lifecycle{
4228+
PostStart: &api.LifecycleHandler{
4229+
Sleep: &api.SleepAction{
4230+
Seconds: 1,
4231+
},
4232+
},
4233+
},
4234+
},
4235+
},
4236+
},
4237+
featureEnabled: false,
4238+
expectAllowPodLifecycleSleepActionZeroValue: false,
4239+
},
4240+
{
4241+
name: "PreStop with zero seconds with feature gate disabled",
4242+
podSpec: &api.PodSpec{
4243+
Containers: []api.Container{
4244+
{
4245+
Lifecycle: &api.Lifecycle{
4246+
PreStop: &api.LifecycleHandler{
4247+
Sleep: &api.SleepAction{
4248+
Seconds: 0,
4249+
},
4250+
},
4251+
},
4252+
},
4253+
},
4254+
},
4255+
featureEnabled: false,
4256+
expectAllowPodLifecycleSleepActionZeroValue: true,
4257+
},
4258+
{
4259+
name: "PostStart with zero seconds with feature gate disabled",
4260+
podSpec: &api.PodSpec{
4261+
Containers: []api.Container{
4262+
{
4263+
Lifecycle: &api.Lifecycle{
4264+
PostStart: &api.LifecycleHandler{
4265+
Sleep: &api.SleepAction{
4266+
Seconds: 0,
4267+
},
4268+
},
4269+
},
4270+
},
4271+
},
4272+
},
4273+
featureEnabled: false,
41904274
expectAllowPodLifecycleSleepActionZeroValue: true,
41914275
},
41924276
}
41934277

41944278
for _, tc := range testCases {
41954279
t.Run(tc.name, func(t *testing.T) {
4280+
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepActionAllowZero, tc.featureEnabled)
4281+
41964282
gotOptions := GetValidationOptionsFromPodSpecAndMeta(&api.PodSpec{}, tc.podSpec, nil, nil)
41974283
assert.Equal(t, tc.expectAllowPodLifecycleSleepActionZeroValue, gotOptions.AllowPodLifecycleSleepActionZeroValue, "AllowPodLifecycleSleepActionZeroValue")
41984284
})

‎pkg/features/kube_features.go

+1
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
15581558

15591559
PodLifecycleSleepActionAllowZero: {
15601560
{Version: version.MustParse("1.32"), Default: false, PreRelease: featuregate.Alpha},
1561+
{Version: version.MustParse("1.33"), Default: true, PreRelease: featuregate.Beta},
15611562
},
15621563

15631564
PodObservedGenerationTracking: {

‎test/compatibility_lifecycle/reference/versioned_feature_list.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,10 @@
10351035
lockToDefault: false
10361036
preRelease: Alpha
10371037
version: "1.32"
1038+
- default: true
1039+
lockToDefault: false
1040+
preRelease: Beta
1041+
version: "1.33"
10381042
- name: PodLogsQuerySplitStreams
10391043
versionedSpecs:
10401044
- default: false

0 commit comments

Comments
 (0)
Please sign in to comment.