Skip to content

Commit 4c487b0

Browse files
authored
Merge pull request kubernetes#128627 from kannon92/revert-128046-ga3960
Revert "Graduate PodLifecycleSleepAction to GA"
2 parents dff657a + 350b0d2 commit 4c487b0

File tree

7 files changed

+18
-31
lines changed

7 files changed

+18
-31
lines changed

pkg/api/pod/util_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3434
"k8s.io/apimachinery/pkg/util/sets"
3535
"k8s.io/apimachinery/pkg/util/validation/field"
36-
"k8s.io/apimachinery/pkg/util/version"
3736
utilfeature "k8s.io/apiserver/pkg/util/feature"
3837
featuregatetesting "k8s.io/component-base/featuregate/testing"
3938
api "k8s.io/kubernetes/pkg/apis/core"
@@ -3402,7 +3401,6 @@ func TestDropPodLifecycleSleepAction(t *testing.T) {
34023401

34033402
for i, tc := range testCases {
34043403
t.Run(fmt.Sprintf("test_%d", i), func(t *testing.T) {
3405-
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, utilfeature.DefaultFeatureGate, version.MustParse("1.31"))
34063404
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepAction, tc.gateEnabled)
34073405

34083406
// preStop

pkg/features/versioned_kube_features.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,6 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
572572
PodLifecycleSleepAction: {
573573
{Version: version.MustParse("1.29"), Default: false, PreRelease: featuregate.Alpha},
574574
{Version: version.MustParse("1.30"), Default: true, PreRelease: featuregate.Beta},
575-
{Version: version.MustParse("1.32"), Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.35 when this version cannot be emulated any longer
576575
},
577576
PodReadyToStartContainersCondition: {
578577
{Version: version.MustParse("1.28"), Default: false, PreRelease: featuregate.Alpha},

pkg/kubelet/lifecycle/handlers_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ import (
3232
v1 "k8s.io/api/core/v1"
3333
"k8s.io/apimachinery/pkg/types"
3434
"k8s.io/apimachinery/pkg/util/intstr"
35+
utilfeature "k8s.io/apiserver/pkg/util/feature"
3536
"k8s.io/client-go/tools/record"
37+
featuregatetesting "k8s.io/component-base/featuregate/testing"
3638
"k8s.io/component-base/metrics/legacyregistry"
3739
"k8s.io/component-base/metrics/testutil"
40+
"k8s.io/kubernetes/pkg/features"
3841
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
3942
"k8s.io/kubernetes/pkg/kubelet/metrics"
4043
"k8s.io/kubernetes/pkg/kubelet/util/format"
@@ -856,6 +859,8 @@ func TestRunSleepHandler(t *testing.T) {
856859

857860
for _, tt := range tests {
858861
t.Run(tt.name, func(t *testing.T) {
862+
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepAction, true)
863+
859864
pod.Spec.Containers[0].Lifecycle.PreStop.Sleep = &v1.SleepAction{Seconds: tt.sleepSeconds}
860865
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(tt.terminationGracePeriodSeconds)*time.Second)
861866
defer cancel()

pkg/registry/core/pod/strategy_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
"k8s.io/apimachinery/pkg/labels"
3737
"k8s.io/apimachinery/pkg/runtime"
3838
"k8s.io/apimachinery/pkg/types"
39-
"k8s.io/apimachinery/pkg/util/version"
4039
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
4140
utilfeature "k8s.io/apiserver/pkg/util/feature"
4241
"k8s.io/apiserver/pkg/warning"
@@ -1870,7 +1869,6 @@ func TestPodLifecycleSleepActionEnablement(t *testing.T) {
18701869

18711870
for _, tc := range testCases {
18721871
t.Run(tc.description, func(t *testing.T) {
1873-
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, utilfeature.DefaultFeatureGate, version.MustParse("1.31"))
18741872
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepAction, tc.gateEnabled)
18751873

18761874
newPod := tc.newPod

test/e2e/common/node/lifecycle_hook.go

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ func validDuration(duration time.Duration, low, high int64) bool {
551551
return duration >= time.Second*time.Duration(low) && duration <= time.Second*time.Duration(high)
552552
}
553553

554-
var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), func() {
554+
var _ = SIGDescribe(feature.PodLifecycleSleepAction, func() {
555555
f := framework.NewDefaultFramework("pod-lifecycle-sleep-action")
556556
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
557557
var podClient *e2epod.PodClient
@@ -560,11 +560,6 @@ var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), fun
560560
ginkgo.BeforeEach(func(ctx context.Context) {
561561
podClient = e2epod.NewPodClient(f)
562562
})
563-
/*
564-
Release : v1.32
565-
Testname: Pod Lifecycle, prestop sleep hook
566-
Description: When a pre-stop handler is specified in the container lifecycle using a 'Sleep' action, then the handler MUST be invoked before the container is terminated. A test pod will be created to verify if its termination time aligns with the sleep time specified when it is terminated.
567-
*/
568563
ginkgo.It("valid prestop hook using sleep action", func(ctx context.Context) {
569564
lifecycle := &v1.Lifecycle{
570565
PreStop: &v1.LifecycleHandler{
@@ -585,40 +580,32 @@ var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), fun
585580
framework.Failf("unexpected delay duration before killing the pod, cost = %v", cost)
586581
}
587582
})
588-
/*
589-
Release : v1.32
590-
Testname: Pod Lifecycle, prestop sleep hook with low gracePeriodSeconds
591-
Description: When a pre-stop handler is specified in the container lifecycle using a 'Sleep' action, then the handler MUST be invoked before the container is terminated. A test pod will be created, and its `gracePeriodSeconds` will be modified to a value less than the sleep time before termination. The termination time will then be checked to ensure it aligns with the `gracePeriodSeconds` value.
592-
*/
583+
593584
ginkgo.It("reduce GracePeriodSeconds during runtime", func(ctx context.Context) {
594585
lifecycle := &v1.Lifecycle{
595586
PreStop: &v1.LifecycleHandler{
596-
Sleep: &v1.SleepAction{Seconds: 30},
587+
Sleep: &v1.SleepAction{Seconds: 15},
597588
},
598589
}
599590
podWithHook := getPodWithHook("pod-with-prestop-sleep-hook", imageutils.GetPauseImageName(), lifecycle)
600591
ginkgo.By("create the pod with lifecycle hook using sleep action")
601592
podClient.CreateSync(ctx, podWithHook)
602593
ginkgo.By("delete the pod with lifecycle hook using sleep action")
603594
start := time.Now()
604-
podClient.DeleteSync(ctx, podWithHook.Name, *metav1.NewDeleteOptions(5), e2epod.DefaultPodDeletionTimeout)
595+
podClient.DeleteSync(ctx, podWithHook.Name, *metav1.NewDeleteOptions(2), e2epod.DefaultPodDeletionTimeout)
605596
cost := time.Since(start)
606597
// cost should be
607-
// longer than 5 seconds (we change gracePeriodSeconds to 5 seconds here, and it's less than sleep action)
598+
// longer than 2 seconds (we change gracePeriodSeconds to 2 seconds here, and it's less than sleep action)
608599
// shorter than sleep action (to make sure it doesn't take effect)
609-
if !validDuration(cost, 5, 15) {
600+
if !validDuration(cost, 2, 15) {
610601
framework.Failf("unexpected delay duration before killing the pod, cost = %v", cost)
611602
}
612603
})
613-
/*
614-
Release : v1.32
615-
Testname: Pod Lifecycle, prestop sleep hook with erroneous startup command
616-
Description: When a pre-stop handler is specified in the container lifecycle using a 'Sleep' action, then the handler MUST be invoked before the container is terminated. A test pod with an erroneous startup command will be created, and upon termination, it will be checked whether it ignored the sleep time.
617-
*/
604+
618605
ginkgo.It("ignore terminated container", func(ctx context.Context) {
619606
lifecycle := &v1.Lifecycle{
620607
PreStop: &v1.LifecycleHandler{
621-
Sleep: &v1.SleepAction{Seconds: 25},
608+
Sleep: &v1.SleepAction{Seconds: 20},
622609
},
623610
}
624611
name := "pod-with-prestop-sleep-hook"
@@ -635,10 +622,11 @@ var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), fun
635622
cost := time.Since(start)
636623
// cost should be
637624
// shorter than sleep action (container is terminated and sleep action should be ignored)
638-
if !validDuration(cost, 0, 25) {
625+
if !validDuration(cost, 0, 15) {
639626
framework.Failf("unexpected delay duration before killing the pod, cost = %v", cost)
640627
}
641628
})
629+
642630
})
643631
})
644632

test/e2e/feature/feature.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ var (
264264
// TODO: document the feature (owning SIG, when to use this feature for a test)
265265
PodGarbageCollector = framework.WithFeature(framework.ValidFeatures.Add("PodGarbageCollector"))
266266

267+
// TODO: document the feature (owning SIG, when to use this feature for a test)
268+
PodLifecycleSleepAction = framework.WithFeature(framework.ValidFeatures.Add("PodLifecycleSleepAction"))
269+
267270
// Owner: sig-node
268271
// Marks a single test that tests Pod Lifecycle Sleep action with zero duration. Requires feature gate PodLifecycleSleepActionAllowZero to be enabled.
269272
PodLifecycleSleepActionAllowZero = framework.WithFeature(framework.ValidFeatures.Add("PodLifecycleSleepActionAllowZero"))

test/featuregates_linter/test_data/versioned_feature_list.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,10 +906,6 @@
906906
lockToDefault: false
907907
preRelease: Beta
908908
version: "1.30"
909-
- default: true
910-
lockToDefault: true
911-
preRelease: GA
912-
version: "1.32"
913909
- name: PodLifecycleSleepActionAllowZero
914910
versionedSpecs:
915911
- default: false

0 commit comments

Comments
 (0)