Skip to content
Open
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
11 changes: 11 additions & 0 deletions pkg/apis/serving/k8s_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,17 @@ func validateProbe(p *corev1.Probe, port *corev1.ContainerPort, isUserContainer
} else if len(handlers) > 1 {
errs = errs.Also(apis.ErrMultipleOneOf(handlers...))
}

// Validate TerminationGracePeriodSeconds if set
if p.TerminationGracePeriodSeconds != nil {
if *p.TerminationGracePeriodSeconds < 0 {
errs = errs.Also(&apis.FieldError{
Message: "terminationGracePeriodSeconds must be non-negative",
Paths: []string{"terminationGracePeriodSeconds"},
})
}
}

return errs
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/serving/v1/revision_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (rs *RevisionSpec) applyDefault(ctx context.Context, container *corev1.Cont
}
rs.applyReadinessProbeDefaults(container)
rs.applyGRPCProbeDefaults(container)
rs.applyLivenessProbeDefaults(container)

if rs.PodSpec.EnableServiceLinks == nil && apis.IsInCreate(ctx) {
rs.PodSpec.EnableServiceLinks = cfg.Defaults.EnableServiceLinks
Expand Down Expand Up @@ -203,6 +204,14 @@ func (*RevisionSpec) applyGRPCProbeDefaults(container *corev1.Container) {
}
}

// applyLivenessProbeDefaults applies default TerminationGracePeriodSeconds to liveness probe
func (*RevisionSpec) applyLivenessProbeDefaults(container *corev1.Container) {
if container.LivenessProbe != nil && container.LivenessProbe.TerminationGracePeriodSeconds == nil {
// Default to 1 second for liveness probe termination grace period
container.LivenessProbe.TerminationGracePeriodSeconds = ptr.Int64(1)
}
}

// Upgrade SecurityContext for this container and the Pod definition to use settings
// for the `restricted` profile when the feature flag is enabled.
// when the feature flag is enabled or AllowRootBounded:
Expand Down