mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #128627 from kannon92/revert-128046-ga3960
Revert "Graduate PodLifecycleSleepAction to GA"
This commit is contained in:
commit
4c487b00af
@ -33,7 +33,6 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
@ -3402,7 +3401,6 @@ func TestDropPodLifecycleSleepAction(t *testing.T) {
|
||||
|
||||
for i, tc := range testCases {
|
||||
t.Run(fmt.Sprintf("test_%d", i), func(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, utilfeature.DefaultFeatureGate, version.MustParse("1.31"))
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepAction, tc.gateEnabled)
|
||||
|
||||
// preStop
|
||||
|
@ -572,7 +572,6 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
|
||||
PodLifecycleSleepAction: {
|
||||
{Version: version.MustParse("1.29"), Default: false, PreRelease: featuregate.Alpha},
|
||||
{Version: version.MustParse("1.30"), Default: true, PreRelease: featuregate.Beta},
|
||||
{Version: version.MustParse("1.32"), Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.35 when this version cannot be emulated any longer
|
||||
},
|
||||
PodReadyToStartContainersCondition: {
|
||||
{Version: version.MustParse("1.28"), Default: false, PreRelease: featuregate.Alpha},
|
||||
|
@ -32,9 +32,12 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/tools/record"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
"k8s.io/component-base/metrics/testutil"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
"k8s.io/kubernetes/pkg/kubelet/metrics"
|
||||
"k8s.io/kubernetes/pkg/kubelet/util/format"
|
||||
@ -856,6 +859,8 @@ func TestRunSleepHandler(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepAction, true)
|
||||
|
||||
pod.Spec.Containers[0].Lifecycle.PreStop.Sleep = &v1.SleepAction{Seconds: tt.sleepSeconds}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(tt.terminationGracePeriodSeconds)*time.Second)
|
||||
defer cancel()
|
||||
|
@ -36,7 +36,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/apiserver/pkg/warning"
|
||||
@ -1870,7 +1869,6 @@ func TestPodLifecycleSleepActionEnablement(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, utilfeature.DefaultFeatureGate, version.MustParse("1.31"))
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodLifecycleSleepAction, tc.gateEnabled)
|
||||
|
||||
newPod := tc.newPod
|
||||
|
@ -551,7 +551,7 @@ func validDuration(duration time.Duration, low, high int64) bool {
|
||||
return duration >= time.Second*time.Duration(low) && duration <= time.Second*time.Duration(high)
|
||||
}
|
||||
|
||||
var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), func() {
|
||||
var _ = SIGDescribe(feature.PodLifecycleSleepAction, func() {
|
||||
f := framework.NewDefaultFramework("pod-lifecycle-sleep-action")
|
||||
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
|
||||
var podClient *e2epod.PodClient
|
||||
@ -560,11 +560,6 @@ var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), fun
|
||||
ginkgo.BeforeEach(func(ctx context.Context) {
|
||||
podClient = e2epod.NewPodClient(f)
|
||||
})
|
||||
/*
|
||||
Release : v1.32
|
||||
Testname: Pod Lifecycle, prestop sleep hook
|
||||
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.
|
||||
*/
|
||||
ginkgo.It("valid prestop hook using sleep action", func(ctx context.Context) {
|
||||
lifecycle := &v1.Lifecycle{
|
||||
PreStop: &v1.LifecycleHandler{
|
||||
@ -585,15 +580,11 @@ var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), fun
|
||||
framework.Failf("unexpected delay duration before killing the pod, cost = %v", cost)
|
||||
}
|
||||
})
|
||||
/*
|
||||
Release : v1.32
|
||||
Testname: Pod Lifecycle, prestop sleep hook with low gracePeriodSeconds
|
||||
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.
|
||||
*/
|
||||
|
||||
ginkgo.It("reduce GracePeriodSeconds during runtime", func(ctx context.Context) {
|
||||
lifecycle := &v1.Lifecycle{
|
||||
PreStop: &v1.LifecycleHandler{
|
||||
Sleep: &v1.SleepAction{Seconds: 30},
|
||||
Sleep: &v1.SleepAction{Seconds: 15},
|
||||
},
|
||||
}
|
||||
podWithHook := getPodWithHook("pod-with-prestop-sleep-hook", imageutils.GetPauseImageName(), lifecycle)
|
||||
@ -601,24 +592,20 @@ var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), fun
|
||||
podClient.CreateSync(ctx, podWithHook)
|
||||
ginkgo.By("delete the pod with lifecycle hook using sleep action")
|
||||
start := time.Now()
|
||||
podClient.DeleteSync(ctx, podWithHook.Name, *metav1.NewDeleteOptions(5), e2epod.DefaultPodDeletionTimeout)
|
||||
podClient.DeleteSync(ctx, podWithHook.Name, *metav1.NewDeleteOptions(2), e2epod.DefaultPodDeletionTimeout)
|
||||
cost := time.Since(start)
|
||||
// cost should be
|
||||
// longer than 5 seconds (we change gracePeriodSeconds to 5 seconds here, and it's less than sleep action)
|
||||
// longer than 2 seconds (we change gracePeriodSeconds to 2 seconds here, and it's less than sleep action)
|
||||
// shorter than sleep action (to make sure it doesn't take effect)
|
||||
if !validDuration(cost, 5, 15) {
|
||||
if !validDuration(cost, 2, 15) {
|
||||
framework.Failf("unexpected delay duration before killing the pod, cost = %v", cost)
|
||||
}
|
||||
})
|
||||
/*
|
||||
Release : v1.32
|
||||
Testname: Pod Lifecycle, prestop sleep hook with erroneous startup command
|
||||
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.
|
||||
*/
|
||||
|
||||
ginkgo.It("ignore terminated container", func(ctx context.Context) {
|
||||
lifecycle := &v1.Lifecycle{
|
||||
PreStop: &v1.LifecycleHandler{
|
||||
Sleep: &v1.SleepAction{Seconds: 25},
|
||||
Sleep: &v1.SleepAction{Seconds: 20},
|
||||
},
|
||||
}
|
||||
name := "pod-with-prestop-sleep-hook"
|
||||
@ -635,10 +622,11 @@ var _ = SIGDescribe("Lifecycle Sleep Hook", framework.WithNodeConformance(), fun
|
||||
cost := time.Since(start)
|
||||
// cost should be
|
||||
// shorter than sleep action (container is terminated and sleep action should be ignored)
|
||||
if !validDuration(cost, 0, 25) {
|
||||
if !validDuration(cost, 0, 15) {
|
||||
framework.Failf("unexpected delay duration before killing the pod, cost = %v", cost)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -264,6 +264,9 @@ var (
|
||||
// TODO: document the feature (owning SIG, when to use this feature for a test)
|
||||
PodGarbageCollector = framework.WithFeature(framework.ValidFeatures.Add("PodGarbageCollector"))
|
||||
|
||||
// TODO: document the feature (owning SIG, when to use this feature for a test)
|
||||
PodLifecycleSleepAction = framework.WithFeature(framework.ValidFeatures.Add("PodLifecycleSleepAction"))
|
||||
|
||||
// Owner: sig-node
|
||||
// Marks a single test that tests Pod Lifecycle Sleep action with zero duration. Requires feature gate PodLifecycleSleepActionAllowZero to be enabled.
|
||||
PodLifecycleSleepActionAllowZero = framework.WithFeature(framework.ValidFeatures.Add("PodLifecycleSleepActionAllowZero"))
|
||||
|
@ -906,10 +906,6 @@
|
||||
lockToDefault: false
|
||||
preRelease: Beta
|
||||
version: "1.30"
|
||||
- default: true
|
||||
lockToDefault: true
|
||||
preRelease: GA
|
||||
version: "1.32"
|
||||
- name: PodLifecycleSleepActionAllowZero
|
||||
versionedSpecs:
|
||||
- default: false
|
||||
|
Loading…
Reference in New Issue
Block a user