Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] Upgrade to latest dependencies #461

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ require (
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
knative.dev/eventing v0.40.1-0.20240311130728-8a18b168acd5
knative.dev/eventing v0.40.1-0.20240312170432-bbb9051e9fd0
knative.dev/hack v0.0.0-20240302114326-e6dedc74dc47
knative.dev/pkg v0.0.0-20240311204931-2c15a6fd07af
knative.dev/serving v0.40.1-0.20240311214815-3e119d571289
knative.dev/serving v0.40.1-0.20240312204407-a194cb210d5e
)

require (
Expand Down Expand Up @@ -100,7 +100,7 @@ require (
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
knative.dev/networking v0.0.0-20240306063647-941710129f7a // indirect
knative.dev/networking v0.0.0-20240311132944-3252e63e3239 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -721,16 +721,16 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/eventing v0.40.1-0.20240311130728-8a18b168acd5 h1:6fomHNpt4YRWtiXUO8Z7TuDsWqhcowoj+pXdTBIAHXk=
knative.dev/eventing v0.40.1-0.20240311130728-8a18b168acd5/go.mod h1:zDgh6w6YNyF47bPVsMt20Fqtz2pgoFdz11FWiFcvwBw=
knative.dev/eventing v0.40.1-0.20240312170432-bbb9051e9fd0 h1:uCaJsFiTl06ULwsqY8NjCvnDxqvSNybUU5Qk9eFBPhg=
knative.dev/eventing v0.40.1-0.20240312170432-bbb9051e9fd0/go.mod h1:cR01SW6iIArmoqN9hSIme8kG1LVwHA7bGltSFvXH9LM=
knative.dev/hack v0.0.0-20240302114326-e6dedc74dc47 h1:ob3nmyZw8vJbvnHQdnDTG/5RDeUKBj5erjTdef/Mpew=
knative.dev/hack v0.0.0-20240302114326-e6dedc74dc47/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/networking v0.0.0-20240306063647-941710129f7a h1:T26doaoObxZrQ5uKHMDnBaXyY/9vmCzphr/9A6yW/UQ=
knative.dev/networking v0.0.0-20240306063647-941710129f7a/go.mod h1:udigmYdmQh3QVHjBmIadENIk0sVNeLh5PWqw2tBL72I=
knative.dev/networking v0.0.0-20240311132944-3252e63e3239 h1:vGLIFxVzXKac/X6OaabW8V88VWnY/tdGTY/64/4mQ50=
knative.dev/networking v0.0.0-20240311132944-3252e63e3239/go.mod h1:WA1iELJea7iqa0jzkoV4JoCanNcFUtvnQNuKkA7/qDw=
knative.dev/pkg v0.0.0-20240311204931-2c15a6fd07af h1:5Qvq9/U4wfvrqASuGN5C0G+zbpoL5SlmwC/iQaPxt14=
knative.dev/pkg v0.0.0-20240311204931-2c15a6fd07af/go.mod h1:sY120AxzRnR/Bx39e9o5WyLGgCNVvmTvRK8ic9ca3AY=
knative.dev/serving v0.40.1-0.20240311214815-3e119d571289 h1:72B505Fqkn2dGJrIYd08RWapkJaW9Uqk/cdoD+baJSE=
knative.dev/serving v0.40.1-0.20240311214815-3e119d571289/go.mod h1:tbBuvAZLzbtA3IW7Vs97EIMgvbfvcFc/dvz9MXzugKQ=
knative.dev/serving v0.40.1-0.20240312204407-a194cb210d5e h1:w1S941lOj4pnI3EtuH/Uvz/OTofgTVbm1BuNwH1Ug8g=
knative.dev/serving v0.40.1-0.20240312204407-a194cb210d5e/go.mod h1:8XlchMQ5/ZyouHPGBCgQGTPxpklw0JuWpL430NjKpF8=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
3 changes: 3 additions & 0 deletions vendor/knative.dev/serving/pkg/apis/config/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (
func defaultFeaturesConfig() *Features {
return &Features{
MultiContainer: Enabled,
MultiContainerProbing: Disabled,
PodSpecAffinity: Disabled,
PodSpecTopologySpreadConstraints: Disabled,
PodSpecDryRun: Allowed,
Expand Down Expand Up @@ -87,6 +88,7 @@ func NewFeaturesConfigFromMap(data map[string]string) (*Features, error) {

if err := cm.Parse(data,
asFlag("multi-container", &nc.MultiContainer),
asFlag("multi-container-probing", &nc.MultiContainerProbing),
asFlag("kubernetes.podspec-affinity", &nc.PodSpecAffinity),
asFlag("kubernetes.podspec-topologyspreadconstraints", &nc.PodSpecTopologySpreadConstraints),
asFlag("kubernetes.podspec-dryrun", &nc.PodSpecDryRun),
Expand Down Expand Up @@ -124,6 +126,7 @@ func NewFeaturesConfigFromConfigMap(config *corev1.ConfigMap) (*Features, error)
// Features specifies which features are allowed by the webhook.
type Features struct {
MultiContainer Flag
MultiContainerProbing Flag
PodSpecAffinity Flag
PodSpecTopologySpreadConstraints Flag
PodSpecDryRun Flag
Expand Down
61 changes: 41 additions & 20 deletions vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func ValidatePodSpec(ctx context.Context, ps corev1.PodSpec) *apis.FieldError {
case 0:
errs = errs.Also(apis.ErrMissingField("containers"))
case 1:
errs = errs.Also(ValidateContainer(ctx, ps.Containers[0], volumes, port).
errs = errs.Also(ValidateUserContainer(ctx, ps.Containers[0], volumes, port).
ViaFieldIndex("containers", 0))
default:
errs = errs.Also(validateContainers(ctx, ps.Containers, volumes, port))
Expand Down Expand Up @@ -447,7 +447,7 @@ func validateContainers(ctx context.Context, containers []corev1.Container, volu
// Note, if we allow readiness/liveness checks on sidecars, we should pass in an *empty* port here, not the main container's port.
errs = errs.Also(validateSidecarContainer(WithinSidecarContainer(ctx), containers[i], volumes).ViaFieldIndex("containers", i))
} else {
errs = errs.Also(ValidateContainer(WithinUserContainer(ctx), containers[i], volumes, port).ViaFieldIndex("containers", i))
errs = errs.Also(ValidateUserContainer(WithinUserContainer(ctx), containers[i], volumes, port).ViaFieldIndex("containers", i))
}
}
return errs
Expand Down Expand Up @@ -503,14 +503,23 @@ func validateContainersPorts(containers []corev1.Container) (corev1.ContainerPor

// validateSidecarContainer validate fields for non serving containers
func validateSidecarContainer(ctx context.Context, container corev1.Container, volumes map[string]corev1.Volume) (errs *apis.FieldError) {
if container.LivenessProbe != nil {
errs = errs.Also(apis.CheckDisallowedFields(*container.LivenessProbe,
*ProbeMask(&corev1.Probe{})).ViaField("livenessProbe"))
}
if container.ReadinessProbe != nil {
errs = errs.Also(apis.CheckDisallowedFields(*container.ReadinessProbe,
*ProbeMask(&corev1.Probe{})).ViaField("readinessProbe"))
cfg := config.FromContextOrDefaults(ctx)
if cfg.Features.MultiContainerProbing != config.Enabled {
if container.LivenessProbe != nil {
errs = errs.Also(apis.CheckDisallowedFields(*container.LivenessProbe,
*ProbeMask(&corev1.Probe{})).ViaField("livenessProbe"))
}
if container.ReadinessProbe != nil {
errs = errs.Also(apis.CheckDisallowedFields(*container.ReadinessProbe,
*ProbeMask(&corev1.Probe{})).ViaField("readinessProbe"))
}
} else if cfg.Features.MultiContainerProbing == config.Enabled {
// Liveness Probes
errs = errs.Also(validateProbe(container.LivenessProbe, nil, false).ViaField("livenessProbe"))
// Readiness Probes
errs = errs.Also(validateReadinessProbe(container.ReadinessProbe, nil, false).ViaField("readinessProbe"))
}

return errs.Also(validate(ctx, container, volumes))
}

Expand Down Expand Up @@ -544,12 +553,12 @@ func validateInitContainer(ctx context.Context, container corev1.Container, volu
return errs.Also(validate(WithinInitContainer(ctx), container, volumes))
}

// ValidateContainer validate fields for serving containers
func ValidateContainer(ctx context.Context, container corev1.Container, volumes map[string]corev1.Volume, port corev1.ContainerPort) (errs *apis.FieldError) {
// ValidateUserContainer validate fields for serving containers
func ValidateUserContainer(ctx context.Context, container corev1.Container, volumes map[string]corev1.Volume, port corev1.ContainerPort) (errs *apis.FieldError) {
// Liveness Probes
errs = errs.Also(validateProbe(container.LivenessProbe, port).ViaField("livenessProbe"))
errs = errs.Also(validateProbe(container.LivenessProbe, &port, true).ViaField("livenessProbe"))
// Readiness Probes
errs = errs.Also(validateReadinessProbe(container.ReadinessProbe, port).ViaField("readinessProbe"))
errs = errs.Also(validateReadinessProbe(container.ReadinessProbe, &port, true).ViaField("readinessProbe"))
return errs.Also(validate(ctx, container, volumes))
}

Expand Down Expand Up @@ -751,12 +760,12 @@ func validateContainerPortBasic(port corev1.ContainerPort) *apis.FieldError {
return errs
}

func validateReadinessProbe(p *corev1.Probe, port corev1.ContainerPort) *apis.FieldError {
func validateReadinessProbe(p *corev1.Probe, port *corev1.ContainerPort, isUserContainer bool) *apis.FieldError {
if p == nil {
return nil
}

errs := validateProbe(p, port)
errs := validateProbe(p, port, isUserContainer)

if p.PeriodSeconds < 0 {
errs = errs.Also(apis.ErrOutOfBoundsValue(p.PeriodSeconds, 0, math.MaxInt32, "periodSeconds"))
Expand Down Expand Up @@ -798,7 +807,7 @@ func validateReadinessProbe(p *corev1.Probe, port corev1.ContainerPort) *apis.Fi
return errs
}

func validateProbe(p *corev1.Probe, port corev1.ContainerPort) *apis.FieldError {
func validateProbe(p *corev1.Probe, port *corev1.ContainerPort, isUserContainer bool) *apis.FieldError {
if p == nil {
return nil
}
Expand All @@ -813,16 +822,28 @@ func validateProbe(p *corev1.Probe, port corev1.ContainerPort) *apis.FieldError
handlers = append(handlers, "httpGet")
errs = errs.Also(apis.CheckDisallowedFields(*h.HTTPGet, *HTTPGetActionMask(h.HTTPGet))).ViaField("httpGet")
getPort := h.HTTPGet.Port
if getPort.StrVal != "" && getPort.StrVal != port.Name {
errs = errs.Also(apis.ErrInvalidValue(getPort.String(), "httpGet.port", "Probe port must match container port"))
if isUserContainer {
if getPort.StrVal != "" && getPort.StrVal != port.Name {
errs = errs.Also(apis.ErrInvalidValue(getPort.String(), "httpGet.port", "Probe port must match container port"))
}
} else {
if getPort.StrVal == "" && getPort.IntVal == 0 {
errs = errs.Also(apis.ErrInvalidValue(getPort.String(), "httpGet.port", "Probe port must be specified"))
}
}
}
if h.TCPSocket != nil {
handlers = append(handlers, "tcpSocket")
errs = errs.Also(apis.CheckDisallowedFields(*h.TCPSocket, *TCPSocketActionMask(h.TCPSocket))).ViaField("tcpSocket")
tcpPort := h.TCPSocket.Port
if tcpPort.StrVal != "" && tcpPort.StrVal != port.Name {
errs = errs.Also(apis.ErrInvalidValue(tcpPort.String(), "tcpSocket.port", "Probe port must match container port"))
if isUserContainer {
if tcpPort.StrVal != "" && tcpPort.StrVal != port.Name {
errs = errs.Also(apis.ErrInvalidValue(tcpPort.String(), "tcpSocket.port", "Probe port must match container port"))
}
} else {
if tcpPort.StrVal == "" && tcpPort.IntVal == 0 {
errs = errs.Also(apis.ErrInvalidValue(tcpPort.String(), "tcpSocket.port", "Probe port must be specified"))
}
}
}
if h.Exec != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ func (rs *RevisionSpec) applyDefault(ctx context.Context, container *corev1.Cont
// If there are multiple containers then default probes will be applied to the container where user specified PORT
// default probes will not be applied for non serving containers
if len(rs.PodSpec.Containers) == 1 || len(container.Ports) != 0 {
rs.applyProbesWithDefaults(container)
rs.applyGRPCProbeDefaults(container)
rs.applyUserContainerDefaultReadinessProbe(container)
}
rs.applyReadinessProbeDefaults(container)
rs.applyGRPCProbeDefaults(container)

if rs.PodSpec.EnableServiceLinks == nil && apis.IsInCreate(ctx) {
rs.PodSpec.EnableServiceLinks = cfg.Defaults.EnableServiceLinks
Expand All @@ -154,7 +155,7 @@ func (rs *RevisionSpec) applyDefault(ctx context.Context, container *corev1.Cont
}
}

func (*RevisionSpec) applyProbesWithDefaults(container *corev1.Container) {
func (*RevisionSpec) applyUserContainerDefaultReadinessProbe(container *corev1.Container) {
if container.ReadinessProbe == nil {
container.ReadinessProbe = &corev1.Probe{}
}
Expand All @@ -164,6 +165,14 @@ func (*RevisionSpec) applyProbesWithDefaults(container *corev1.Container) {
container.ReadinessProbe.GRPC == nil {
container.ReadinessProbe.TCPSocket = &corev1.TCPSocketAction{}
}
}

func (*RevisionSpec) applyReadinessProbeDefaults(container *corev1.Container) {
if container.ReadinessProbe == nil {
// Sidecars are allowed to not have a readiness-probe
// we do not want the defaults in that case.
return
}

if container.ReadinessProbe.SuccessThreshold == 0 {
container.ReadinessProbe.SuccessThreshold = 1
Expand Down
19 changes: 19 additions & 0 deletions vendor/knative.dev/serving/pkg/apis/serving/v1/revision_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const (
// It is never nil and should be exactly the specified container if len(containers) == 1 or
// if there are multiple containers it returns the container which has Ports
// as guaranteed by validation.
// Note: If you change this function, also update GetSidecarContainers.
func (rs *RevisionSpec) GetContainer() *corev1.Container {
switch {
case len(rs.Containers) == 1:
Expand All @@ -86,6 +87,24 @@ func (rs *RevisionSpec) GetContainer() *corev1.Container {
return &corev1.Container{}
}

// GetSidecarContainers returns a slice of pointers to all sidecar containers.
// If len(containers) == 1 OR only one container with a user-port exists, it will return an empty slice.
// It is the "rest" of GetContainer.
func (rs *RevisionSpec) GetSidecarContainers() []*corev1.Container {
sidecars := []*corev1.Container{}
if len(rs.Containers) == 1 {
return sidecars
}

for i, c := range rs.Containers {
if len(c.Ports) == 0 {
sidecars = append(sidecars, &rs.Containers[i])
}
}

return sidecars
}

// SetRoutingState sets the routingState label on this Revision and updates the
// routingStateModified annotation.
func (r *Revision) SetRoutingState(state RoutingState, tm time.Time) {
Expand Down
6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ k8s.io/utils/pointer
k8s.io/utils/ptr
k8s.io/utils/strings/slices
k8s.io/utils/trace
# knative.dev/eventing v0.40.1-0.20240311130728-8a18b168acd5
# knative.dev/eventing v0.40.1-0.20240312170432-bbb9051e9fd0
## explicit; go 1.21
knative.dev/eventing/pkg/adapter/v2
knative.dev/eventing/pkg/adapter/v2/test
Expand All @@ -970,7 +970,7 @@ knative.dev/eventing/pkg/reconciler/source
# knative.dev/hack v0.0.0-20240302114326-e6dedc74dc47
## explicit; go 1.18
knative.dev/hack
# knative.dev/networking v0.0.0-20240306063647-941710129f7a
# knative.dev/networking v0.0.0-20240311132944-3252e63e3239
## explicit; go 1.21
knative.dev/networking/pkg/apis/networking
knative.dev/networking/pkg/apis/networking/v1alpha1
Expand Down Expand Up @@ -1038,7 +1038,7 @@ knative.dev/pkg/webhook/psbinding
knative.dev/pkg/webhook/resourcesemantics
knative.dev/pkg/webhook/resourcesemantics/defaulting
knative.dev/pkg/webhook/resourcesemantics/validation
# knative.dev/serving v0.40.1-0.20240311214815-3e119d571289
# knative.dev/serving v0.40.1-0.20240312204407-a194cb210d5e
## explicit; go 1.21
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1
Expand Down
Loading