From 9327f3a1734fbbd354d1cc91ee4794b83a1025c1 Mon Sep 17 00:00:00 2001 From: AxeZhan Date: Fri, 18 Aug 2023 13:20:52 +0800 Subject: [PATCH] api changes --- pkg/apis/core/types.go | 10 ++++++++++ pkg/features/kube_features.go | 9 +++++++++ staging/src/k8s.io/api/core/v1/types.go | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index e40b8bfa104..b57618d9992 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -2150,6 +2150,12 @@ type ExecAction struct { Command []string } +// SleepAction describes a "sleep" action. +type SleepAction struct { + // Seconds is the number of seconds to sleep. + Seconds int64 +} + // Probe describes a health check to be performed against a container to determine whether it is // alive or ready to receive traffic. type Probe struct { @@ -2432,6 +2438,10 @@ type LifecycleHandler struct { // lifecycle hooks will fail in runtime when tcp handler is specified. // +optional TCPSocket *TCPSocketAction + // Sleep represents the duration that the container should sleep before being terminated. + // +featureGate=PodLifecycleSleepAction + // +optional + Sleep *SleepAction } type GRPCAction struct { diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 26e7024d542..ca36f2299f8 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -636,6 +636,13 @@ const ( // Adds pod.status.hostIPs and downward API PodHostIPs featuregate.Feature = "PodHostIPs" + // owner: @AxeZhan + // kep: http://kep.k8s.io/3960 + // alpha: v1.29 + // + // Enables SleepAction in container lifecycle hooks + PodLifecycleSleepAction featuregate.Feature = "PodLifecycleSleepAction" + // owner: @Huang-Wei // kep: https://kep.k8s.io/3521 // alpha: v1.26 @@ -1063,6 +1070,8 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS PodHostIPs: {Default: false, PreRelease: featuregate.Alpha}, + PodLifecycleSleepAction: {Default: false, PreRelease: featuregate.Alpha}, + PodSchedulingReadiness: {Default: true, PreRelease: featuregate.Beta}, ProbeTerminationGracePeriod: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.29 diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index 698590db85b..cc8cef943f3 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -2272,6 +2272,12 @@ type ExecAction struct { Command []string `json:"command,omitempty" protobuf:"bytes,1,rep,name=command"` } +// SleepAction describes a "sleep" action. +type SleepAction struct { + // Seconds is the number of seconds to sleep. + Seconds int64 `json:"seconds" protobuf:"bytes,1,opt,name=seconds"` +} + // Probe describes a health check to be performed against a container to determine whether it is // alive or ready to receive traffic. type Probe struct { @@ -2667,6 +2673,10 @@ type LifecycleHandler struct { // lifecycle hooks will fail in runtime when tcp handler is specified. // +optional TCPSocket *TCPSocketAction `json:"tcpSocket,omitempty" protobuf:"bytes,3,opt,name=tcpSocket"` + // Sleep represents the duration that the container should sleep before being terminated. + // +featureGate=PodLifecycleSleepAction + // +optional + Sleep *SleepAction `json:"sleep,omitempty" protobuf:"bytes,4,opt,name=sleep"` } // Lifecycle describes actions that the management system should take in response to container lifecycle