Skip to content

Commit

Permalink
Revert "Merge pull request kubernetes#119026 from AxeZhan/sleepAction"
Browse files Browse the repository at this point in the history
This reverts commit f6ba25f, reversing
changes made to b5ba899.
  • Loading branch information
aojea committed Oct 18, 2023
1 parent d953755 commit 6ea3807
Show file tree
Hide file tree
Showing 81 changed files with 994 additions and 2,331 deletions.
18 changes: 0 additions & 18 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions api/openapi-spec/v3/api__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2901,14 +2901,6 @@
],
"description": "HTTPGet specifies the http request to perform."
},
"sleep": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.core.v1.SleepAction"
}
],
"description": "Sleep represents the duration that the container should sleep before being terminated."
},
"tcpSocket": {
"allOf": [
{
Expand Down Expand Up @@ -7365,21 +7357,6 @@
},
"type": "object"
},
"io.k8s.api.core.v1.SleepAction": {
"description": "SleepAction describes a \"sleep\" action.",
"properties": {
"seconds": {
"default": 0,
"description": "Seconds is the number of seconds to sleep.",
"format": "int64",
"type": "integer"
}
},
"required": [
"seconds"
],
"type": "object"
},
"io.k8s.api.core.v1.StorageOSPersistentVolumeSource": {
"description": "Represents a StorageOS persistent volume resource.",
"properties": {
Expand Down
23 changes: 0 additions & 23 deletions api/openapi-spec/v3/apis__apps__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2760,14 +2760,6 @@
],
"description": "HTTPGet specifies the http request to perform."
},
"sleep": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.core.v1.SleepAction"
}
],
"description": "Sleep represents the duration that the container should sleep before being terminated."
},
"tcpSocket": {
"allOf": [
{
Expand Down Expand Up @@ -4446,21 +4438,6 @@
],
"type": "object"
},
"io.k8s.api.core.v1.SleepAction": {
"description": "SleepAction describes a \"sleep\" action.",
"properties": {
"seconds": {
"default": 0,
"description": "Seconds is the number of seconds to sleep.",
"format": "int64",
"type": "integer"
}
},
"required": [
"seconds"
],
"type": "object"
},
"io.k8s.api.core.v1.StorageOSVolumeSource": {
"description": "Represents a StorageOS persistent volume resource.",
"properties": {
Expand Down
23 changes: 0 additions & 23 deletions api/openapi-spec/v3/apis__batch__v1_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2073,14 +2073,6 @@
],
"description": "HTTPGet specifies the http request to perform."
},
"sleep": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.core.v1.SleepAction"
}
],
"description": "Sleep represents the duration that the container should sleep before being terminated."
},
"tcpSocket": {
"allOf": [
{
Expand Down Expand Up @@ -3637,21 +3629,6 @@
],
"type": "object"
},
"io.k8s.api.core.v1.SleepAction": {
"description": "SleepAction describes a \"sleep\" action.",
"properties": {
"seconds": {
"default": 0,
"description": "Seconds is the number of seconds to sleep.",
"format": "int64",
"type": "integer"
}
},
"required": [
"seconds"
],
"type": "object"
},
"io.k8s.api.core.v1.StorageOSVolumeSource": {
"description": "Represents a StorageOS persistent volume resource.",
"properties": {
Expand Down
58 changes: 0 additions & 58 deletions pkg/api/pod/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,64 +558,6 @@ func dropDisabledFields(
}
// For other types of containers, validateContainers will handle them.
}

if !utilfeature.DefaultFeatureGate.Enabled(features.PodLifecycleSleepAction) && !podLifecycleSleepActionInUse(oldPodSpec) {
for i := range podSpec.Containers {
if podSpec.Containers[i].Lifecycle == nil {
continue
}
if podSpec.Containers[i].Lifecycle.PreStop != nil {
podSpec.Containers[i].Lifecycle.PreStop.Sleep = nil
}
if podSpec.Containers[i].Lifecycle.PostStart != nil {
podSpec.Containers[i].Lifecycle.PostStart.Sleep = nil
}
}
for i := range podSpec.InitContainers {
if podSpec.InitContainers[i].Lifecycle == nil {
continue
}
if podSpec.InitContainers[i].Lifecycle.PreStop != nil {
podSpec.InitContainers[i].Lifecycle.PreStop.Sleep = nil
}
if podSpec.InitContainers[i].Lifecycle.PostStart != nil {
podSpec.InitContainers[i].Lifecycle.PostStart.Sleep = nil
}
}
for i := range podSpec.EphemeralContainers {
if podSpec.EphemeralContainers[i].Lifecycle == nil {
continue
}
if podSpec.EphemeralContainers[i].Lifecycle.PreStop != nil {
podSpec.EphemeralContainers[i].Lifecycle.PreStop.Sleep = nil
}
if podSpec.EphemeralContainers[i].Lifecycle.PostStart != nil {
podSpec.EphemeralContainers[i].Lifecycle.PostStart.Sleep = nil
}
}
}
}

func podLifecycleSleepActionInUse(podSpec *api.PodSpec) bool {
if podSpec == nil {
return false
}
var inUse bool
VisitContainers(podSpec, AllContainers, func(c *api.Container, containerType ContainerType) bool {
if c.Lifecycle == nil {
return true
}
if c.Lifecycle.PreStop != nil && c.Lifecycle.PreStop.Sleep != nil {
inUse = true
return false
}
if c.Lifecycle.PostStart != nil && c.Lifecycle.PostStart.Sleep != nil {
inUse = true
return false
}
return true
})
return inUse
}

// dropDisabledPodStatusFields removes disabled fields from the pod status
Expand Down
10 changes: 0 additions & 10 deletions pkg/apis/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2150,12 +2150,6 @@ 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 {
Expand Down Expand Up @@ -2438,10 +2432,6 @@ 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 {
Expand Down
32 changes: 0 additions & 32 deletions pkg/apis/core/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6ea3807

Please sign in to comment.