startupProbe: API changes

This commit is contained in:
Matthias Bertschy
2019-08-07 10:21:48 +02:00
parent 4495d09282
commit e4d26f845e
6 changed files with 76 additions and 6 deletions

View File

@@ -1924,7 +1924,7 @@ type Probe struct {
// +optional
PeriodSeconds int32
// Minimum consecutive successes for the probe to be considered successful after having failed.
// Must be 1 for liveness.
// Must be 1 for liveness and startup.
// +optional
SuccessThreshold int32
// Minimum consecutive failures for the probe to be considered failed after having succeeded.
@@ -2042,6 +2042,8 @@ type Container struct {
// +optional
ReadinessProbe *Probe
// +optional
StartupProbe *Probe
// +optional
Lifecycle *Lifecycle
// Required.
// +optional
@@ -2090,7 +2092,7 @@ type Lifecycle struct {
// +optional
PostStart *Handler
// PreStop is called immediately before a container is terminated due to an
// API request or management event such as liveness probe failure,
// API request or management event such as liveness/startup probe failure,
// preemption, resource contention, etc. The handler is not called if the
// container crashes or exits. The reason for termination is passed to the
// handler. The Pod's termination grace period countdown begins before the
@@ -2174,6 +2176,7 @@ type ContainerStatus struct {
ImageID string
// +optional
ContainerID string
Started *bool
}
// PodPhase is a label for the condition of a pod at the current time.
@@ -2936,6 +2939,9 @@ type EphemeralContainerCommon struct {
// Probes are not allowed for ephemeral containers.
// +optional
ReadinessProbe *Probe
// Probes are not allowed for ephemeral containers.
// +optional
StartupProbe *Probe
// Lifecycle is not allowed for ephemeral containers.
// +optional
Lifecycle *Lifecycle

View File

@@ -2696,6 +2696,9 @@ func validateInitContainers(containers, otherContainers []core.Container, device
if ctr.ReadinessProbe != nil {
allErrs = append(allErrs, field.Invalid(idxPath.Child("readinessProbe"), ctr.ReadinessProbe, "must not be set for init containers"))
}
if ctr.StartupProbe != nil {
allErrs = append(allErrs, field.Invalid(idxPath.Child("startupProbe"), ctr.StartupProbe, "must not be set for init containers"))
}
}
return allErrs
}
@@ -2738,6 +2741,11 @@ func validateContainers(containers []core.Container, isInitContainers bool, volu
if ctr.LivenessProbe != nil && ctr.LivenessProbe.SuccessThreshold != 1 {
allErrs = append(allErrs, field.Invalid(idxPath.Child("livenessProbe", "successThreshold"), ctr.LivenessProbe.SuccessThreshold, "must be 1"))
}
allErrs = append(allErrs, validateProbe(ctr.StartupProbe, idxPath.Child("startupProbe"))...)
// Startup-specific validation
if ctr.StartupProbe != nil && ctr.StartupProbe.SuccessThreshold != 1 {
allErrs = append(allErrs, field.Invalid(idxPath.Child("startupProbe", "successThreshold"), ctr.StartupProbe.SuccessThreshold, "must be 1"))
}
switch ctr.TerminationMessagePolicy {
case core.TerminationMessageReadFile, core.TerminationMessageFallbackToLogsOnError: