De-share the Handler struct in core API (#105979)

* De-share the Handler struct in core API

An upcoming PR adds a handler that only applies on one of these paths.
Having fields that don't work seems bad.

This never should have been shared.  Lifecycle hooks are like a "write"
while probes are more like a "read". HTTPGet and TCPSocket don't really
make sense as lifecycle hooks (but I can't take that back). When we add
gRPC, it is EXPLICITLY a health check (defined by gRPC) not an arbitrary
RPC - so a probe makes sense but a hook does not.

In the future I can also see adding lifecycle hooks that don't make
sense as probes.  E.g. 'sleep' is a common lifecycle request. The only
option is `exec`, which requires having a sleep binary in your image.

* Run update scripts

Kubernetes-commit: 11a25bfeb6fd6e8e5c42e316b17cea15a702041c
This commit is contained in:
Tim Hockin 2021-10-29 13:15:11 -07:00 committed by Kubernetes Publisher
parent 5be956ba48
commit fd0a0345b3
8 changed files with 98 additions and 39 deletions

View File

@ -21,8 +21,8 @@ package v1
// LifecycleApplyConfiguration represents an declarative configuration of the Lifecycle type for use
// with apply.
type LifecycleApplyConfiguration struct {
PostStart *HandlerApplyConfiguration `json:"postStart,omitempty"`
PreStop *HandlerApplyConfiguration `json:"preStop,omitempty"`
PostStart *LifecycleHandlerApplyConfiguration `json:"postStart,omitempty"`
PreStop *LifecycleHandlerApplyConfiguration `json:"preStop,omitempty"`
}
// LifecycleApplyConfiguration constructs an declarative configuration of the Lifecycle type for use with
@ -34,7 +34,7 @@ func Lifecycle() *LifecycleApplyConfiguration {
// WithPostStart sets the PostStart field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PostStart field is set to the value of the last call.
func (b *LifecycleApplyConfiguration) WithPostStart(value *HandlerApplyConfiguration) *LifecycleApplyConfiguration {
func (b *LifecycleApplyConfiguration) WithPostStart(value *LifecycleHandlerApplyConfiguration) *LifecycleApplyConfiguration {
b.PostStart = value
return b
}
@ -42,7 +42,7 @@ func (b *LifecycleApplyConfiguration) WithPostStart(value *HandlerApplyConfigura
// WithPreStop sets the PreStop field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PreStop field is set to the value of the last call.
func (b *LifecycleApplyConfiguration) WithPreStop(value *HandlerApplyConfiguration) *LifecycleApplyConfiguration {
func (b *LifecycleApplyConfiguration) WithPreStop(value *LifecycleHandlerApplyConfiguration) *LifecycleApplyConfiguration {
b.PreStop = value
return b
}

View File

@ -0,0 +1,57 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1
// LifecycleHandlerApplyConfiguration represents an declarative configuration of the LifecycleHandler type for use
// with apply.
type LifecycleHandlerApplyConfiguration struct {
Exec *ExecActionApplyConfiguration `json:"exec,omitempty"`
HTTPGet *HTTPGetActionApplyConfiguration `json:"httpGet,omitempty"`
TCPSocket *TCPSocketActionApplyConfiguration `json:"tcpSocket,omitempty"`
}
// LifecycleHandlerApplyConfiguration constructs an declarative configuration of the LifecycleHandler type for use with
// apply.
func LifecycleHandler() *LifecycleHandlerApplyConfiguration {
return &LifecycleHandlerApplyConfiguration{}
}
// WithExec sets the Exec field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Exec field is set to the value of the last call.
func (b *LifecycleHandlerApplyConfiguration) WithExec(value *ExecActionApplyConfiguration) *LifecycleHandlerApplyConfiguration {
b.Exec = value
return b
}
// WithHTTPGet sets the HTTPGet field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the HTTPGet field is set to the value of the last call.
func (b *LifecycleHandlerApplyConfiguration) WithHTTPGet(value *HTTPGetActionApplyConfiguration) *LifecycleHandlerApplyConfiguration {
b.HTTPGet = value
return b
}
// WithTCPSocket sets the TCPSocket field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the TCPSocket field is set to the value of the last call.
func (b *LifecycleHandlerApplyConfiguration) WithTCPSocket(value *TCPSocketActionApplyConfiguration) *LifecycleHandlerApplyConfiguration {
b.TCPSocket = value
return b
}

View File

@ -21,13 +21,13 @@ package v1
// ProbeApplyConfiguration represents an declarative configuration of the Probe type for use
// with apply.
type ProbeApplyConfiguration struct {
HandlerApplyConfiguration `json:",inline"`
InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"`
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
PeriodSeconds *int32 `json:"periodSeconds,omitempty"`
SuccessThreshold *int32 `json:"successThreshold,omitempty"`
FailureThreshold *int32 `json:"failureThreshold,omitempty"`
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
ProbeHandlerApplyConfiguration `json:",inline"`
InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"`
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
PeriodSeconds *int32 `json:"periodSeconds,omitempty"`
SuccessThreshold *int32 `json:"successThreshold,omitempty"`
FailureThreshold *int32 `json:"failureThreshold,omitempty"`
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
}
// ProbeApplyConfiguration constructs an declarative configuration of the Probe type for use with

View File

@ -18,24 +18,24 @@ limitations under the License.
package v1
// HandlerApplyConfiguration represents an declarative configuration of the Handler type for use
// ProbeHandlerApplyConfiguration represents an declarative configuration of the ProbeHandler type for use
// with apply.
type HandlerApplyConfiguration struct {
type ProbeHandlerApplyConfiguration struct {
Exec *ExecActionApplyConfiguration `json:"exec,omitempty"`
HTTPGet *HTTPGetActionApplyConfiguration `json:"httpGet,omitempty"`
TCPSocket *TCPSocketActionApplyConfiguration `json:"tcpSocket,omitempty"`
}
// HandlerApplyConfiguration constructs an declarative configuration of the Handler type for use with
// ProbeHandlerApplyConfiguration constructs an declarative configuration of the ProbeHandler type for use with
// apply.
func Handler() *HandlerApplyConfiguration {
return &HandlerApplyConfiguration{}
func ProbeHandler() *ProbeHandlerApplyConfiguration {
return &ProbeHandlerApplyConfiguration{}
}
// WithExec sets the Exec field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the Exec field is set to the value of the last call.
func (b *HandlerApplyConfiguration) WithExec(value *ExecActionApplyConfiguration) *HandlerApplyConfiguration {
func (b *ProbeHandlerApplyConfiguration) WithExec(value *ExecActionApplyConfiguration) *ProbeHandlerApplyConfiguration {
b.Exec = value
return b
}
@ -43,7 +43,7 @@ func (b *HandlerApplyConfiguration) WithExec(value *ExecActionApplyConfiguration
// WithHTTPGet sets the HTTPGet field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the HTTPGet field is set to the value of the last call.
func (b *HandlerApplyConfiguration) WithHTTPGet(value *HTTPGetActionApplyConfiguration) *HandlerApplyConfiguration {
func (b *ProbeHandlerApplyConfiguration) WithHTTPGet(value *HTTPGetActionApplyConfiguration) *ProbeHandlerApplyConfiguration {
b.HTTPGet = value
return b
}
@ -51,7 +51,7 @@ func (b *HandlerApplyConfiguration) WithHTTPGet(value *HTTPGetActionApplyConfigu
// WithTCPSocket sets the TCPSocket field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the TCPSocket field is set to the value of the last call.
func (b *HandlerApplyConfiguration) WithTCPSocket(value *TCPSocketActionApplyConfiguration) *HandlerApplyConfiguration {
func (b *ProbeHandlerApplyConfiguration) WithTCPSocket(value *TCPSocketActionApplyConfiguration) *ProbeHandlerApplyConfiguration {
b.TCPSocket = value
return b
}

View File

@ -4199,18 +4199,6 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: io.k8s.api.core.v1.Handler
map:
fields:
- name: exec
type:
namedType: io.k8s.api.core.v1.ExecAction
- name: httpGet
type:
namedType: io.k8s.api.core.v1.HTTPGetAction
- name: tcpSocket
type:
namedType: io.k8s.api.core.v1.TCPSocketAction
- name: io.k8s.api.core.v1.HostAlias
map:
fields:
@ -4336,10 +4324,22 @@ var schemaYAML = typed.YAMLObject(`types:
fields:
- name: postStart
type:
namedType: io.k8s.api.core.v1.Handler
namedType: io.k8s.api.core.v1.LifecycleHandler
- name: preStop
type:
namedType: io.k8s.api.core.v1.Handler
namedType: io.k8s.api.core.v1.LifecycleHandler
- name: io.k8s.api.core.v1.LifecycleHandler
map:
fields:
- name: exec
type:
namedType: io.k8s.api.core.v1.ExecAction
- name: httpGet
type:
namedType: io.k8s.api.core.v1.HTTPGetAction
- name: tcpSocket
type:
namedType: io.k8s.api.core.v1.TCPSocketAction
- name: io.k8s.api.core.v1.LimitRange
map:
fields:

View File

@ -551,8 +551,6 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationscorev1.GlusterfsPersistentVolumeSourceApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("GlusterfsVolumeSource"):
return &applyconfigurationscorev1.GlusterfsVolumeSourceApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("Handler"):
return &applyconfigurationscorev1.HandlerApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("HostAlias"):
return &applyconfigurationscorev1.HostAliasApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("HostPathVolumeSource"):
@ -569,6 +567,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationscorev1.KeyToPathApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("Lifecycle"):
return &applyconfigurationscorev1.LifecycleApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("LifecycleHandler"):
return &applyconfigurationscorev1.LifecycleHandlerApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("LimitRange"):
return &applyconfigurationscorev1.LimitRangeApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("LimitRangeItem"):
@ -683,6 +683,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationscorev1.PreferredSchedulingTermApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("Probe"):
return &applyconfigurationscorev1.ProbeApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("ProbeHandler"):
return &applyconfigurationscorev1.ProbeHandlerApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("ProjectedVolumeSource"):
return &applyconfigurationscorev1.ProjectedVolumeSourceApplyConfiguration{}
case corev1.SchemeGroupVersion.WithKind("QuobyteVolumeSource"):

4
go.mod
View File

@ -30,7 +30,7 @@ require (
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
google.golang.org/protobuf v1.26.0
k8s.io/api v0.0.0-20211029083603-41019181ea88
k8s.io/api v0.0.0-20211029201511-cca52a076791
k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a
k8s.io/klog/v2 v2.30.0
k8s.io/kube-openapi v0.0.0-20210817084001-7fbd8d59e5b8
@ -40,6 +40,6 @@ require (
)
replace (
k8s.io/api => k8s.io/api v0.0.0-20211029083603-41019181ea88
k8s.io/api => k8s.io/api v0.0.0-20211029201511-cca52a076791
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a
)

4
go.sum
View File

@ -598,8 +598,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20211029083603-41019181ea88 h1:fNrtAsJFqgYBBCed0914pfMwaOUnYg8Ygl43m5Ow+RM=
k8s.io/api v0.0.0-20211029083603-41019181ea88/go.mod h1:dx3B5TOvDwqR2Oqn8muvHae5vt+xIgmxap/fvP+iItQ=
k8s.io/api v0.0.0-20211029201511-cca52a076791 h1:d7AqOEjufZ9cuB97JXVjyvpwonRKyphG0aLfK7+dBNI=
k8s.io/api v0.0.0-20211029201511-cca52a076791/go.mod h1:dx3B5TOvDwqR2Oqn8muvHae5vt+xIgmxap/fvP+iItQ=
k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a h1:3NA1KMmF0ie/tLSNnA3v1ihGjVX7Z5OmZIyAOm0YmVo=
k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a/go.mod h1:oyH3LcOKLLooQH1NlpHlilzkWxqsiHWETyHgssntcXg=
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=