Merge pull request #130621 from sreeram-venkitesh/4818-sleep-action-zero-value-beta-graduation

KEP 4818: PodLifecycleSleepActionAllowZero to Beta
This commit is contained in:
Kubernetes Prow Robot 2025-03-20 13:08:39 -07:00 committed by GitHub
commit 2546557012
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 96 additions and 5 deletions

View File

@ -4114,12 +4114,14 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
testCases := []struct {
name string
podSpec *api.PodSpec
featureEnabled bool
expectAllowPodLifecycleSleepActionZeroValue bool
}{
{
name: "no lifecycle hooks",
podSpec: &api.PodSpec{},
expectAllowPodLifecycleSleepActionZeroValue: false,
name: "no lifecycle hooks",
podSpec: &api.PodSpec{},
featureEnabled: true,
expectAllowPodLifecycleSleepActionZeroValue: true,
},
{
name: "Prestop with non-zero second duration",
@ -4136,7 +4138,8 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
},
},
},
expectAllowPodLifecycleSleepActionZeroValue: false,
featureEnabled: true,
expectAllowPodLifecycleSleepActionZeroValue: true,
},
{
name: "PostStart with non-zero second duration",
@ -4153,7 +4156,8 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
},
},
},
expectAllowPodLifecycleSleepActionZeroValue: false,
featureEnabled: true,
expectAllowPodLifecycleSleepActionZeroValue: true,
},
{
name: "PreStop with zero seconds",
@ -4170,6 +4174,7 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
},
},
},
featureEnabled: true,
expectAllowPodLifecycleSleepActionZeroValue: true,
},
{
@ -4187,12 +4192,93 @@ func TestValidateAllowPodLifecycleSleepActionZeroValue(t *testing.T) {
},
},
},
featureEnabled: true,
expectAllowPodLifecycleSleepActionZeroValue: true,
},
{
name: "no lifecycle hooks with feature gate disabled",
podSpec: &api.PodSpec{},
featureEnabled: false,
expectAllowPodLifecycleSleepActionZeroValue: false,
},
{
name: "Prestop with non-zero second duration with feature gate disabled",
podSpec: &api.PodSpec{
Containers: []api.Container{
{
Lifecycle: &api.Lifecycle{
PreStop: &api.LifecycleHandler{
Sleep: &api.SleepAction{
Seconds: 1,
},
},
},
},
},
},
featureEnabled: false,
expectAllowPodLifecycleSleepActionZeroValue: false,
},
{
name: "PostStart with non-zero second duration with feature gate disabled",
podSpec: &api.PodSpec{
Containers: []api.Container{
{
Lifecycle: &api.Lifecycle{
PostStart: &api.LifecycleHandler{
Sleep: &api.SleepAction{
Seconds: 1,
},
},
},
},
},
},
featureEnabled: false,
expectAllowPodLifecycleSleepActionZeroValue: false,
},
{
name: "PreStop with zero seconds with feature gate disabled",
podSpec: &api.PodSpec{
Containers: []api.Container{
{
Lifecycle: &api.Lifecycle{
PreStop: &api.LifecycleHandler{
Sleep: &api.SleepAction{
Seconds: 0,
},
},
},
},
},
},
featureEnabled: false,
expectAllowPodLifecycleSleepActionZeroValue: true,
},
{
name: "PostStart with zero seconds with feature gate disabled",
podSpec: &api.PodSpec{
Containers: []api.Container{
{
Lifecycle: &api.Lifecycle{
PostStart: &api.LifecycleHandler{
Sleep: &api.SleepAction{
Seconds: 0,
},
},
},
},
},
},
featureEnabled: false,
expectAllowPodLifecycleSleepActionZeroValue: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepActionAllowZero, tc.featureEnabled)
gotOptions := GetValidationOptionsFromPodSpecAndMeta(&api.PodSpec{}, tc.podSpec, nil, nil)
assert.Equal(t, tc.expectAllowPodLifecycleSleepActionZeroValue, gotOptions.AllowPodLifecycleSleepActionZeroValue, "AllowPodLifecycleSleepActionZeroValue")
})

View File

@ -1558,6 +1558,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
PodLifecycleSleepActionAllowZero: {
{Version: version.MustParse("1.32"), Default: false, PreRelease: featuregate.Alpha},
{Version: version.MustParse("1.33"), Default: true, PreRelease: featuregate.Beta},
},
PodObservedGenerationTracking: {

View File

@ -1035,6 +1035,10 @@
lockToDefault: false
preRelease: Alpha
version: "1.32"
- default: true
lockToDefault: false
preRelease: Beta
version: "1.33"
- name: PodLogsQuerySplitStreams
versionedSpecs:
- default: false