mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Add validateStartupProbe
This commit is contained in:
		@@ -2816,6 +2816,19 @@ func validatePodResourceClaimSource(claimSource core.ClaimSource, fldPath *field
 | 
			
		||||
	return allErrs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func validateStartupProbe(probe *core.Probe, fldPath *field.Path) field.ErrorList {
 | 
			
		||||
	allErrs := field.ErrorList{}
 | 
			
		||||
 | 
			
		||||
	if probe == nil {
 | 
			
		||||
		return allErrs
 | 
			
		||||
	}
 | 
			
		||||
	allErrs = append(allErrs, validateProbe(probe, fldPath)...)
 | 
			
		||||
	if probe.SuccessThreshold != 1 {
 | 
			
		||||
		allErrs = append(allErrs, field.Invalid(fldPath.Child("successThreshold"), probe.SuccessThreshold, "must be 1"))
 | 
			
		||||
	}
 | 
			
		||||
	return allErrs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func validateProbe(probe *core.Probe, fldPath *field.Path) field.ErrorList {
 | 
			
		||||
	allErrs := field.ErrorList{}
 | 
			
		||||
 | 
			
		||||
@@ -3214,10 +3227,7 @@ func validateInitContainers(containers []core.Container, regularContainers []cor
 | 
			
		||||
			if ctr.ReadinessProbe != nil {
 | 
			
		||||
				allErrs = append(allErrs, field.Forbidden(idxPath.Child("readinessProbe"), "may not be set for init containers"))
 | 
			
		||||
			}
 | 
			
		||||
			allErrs = append(allErrs, validateProbe(ctr.StartupProbe, idxPath.Child("startupProbe"))...)
 | 
			
		||||
			if ctr.StartupProbe != nil && ctr.StartupProbe.SuccessThreshold != 1 {
 | 
			
		||||
				allErrs = append(allErrs, field.Invalid(idxPath.Child("startupProbe", "successThreshold"), ctr.StartupProbe.SuccessThreshold, "must be 1"))
 | 
			
		||||
			}
 | 
			
		||||
			allErrs = append(allErrs, validateStartupProbe(ctr.StartupProbe, idxPath.Child("startupProbe"))...)
 | 
			
		||||
 | 
			
		||||
		default:
 | 
			
		||||
			// These fields are disallowed for init containers.
 | 
			
		||||
@@ -3231,7 +3241,7 @@ func validateInitContainers(containers []core.Container, regularContainers []cor
 | 
			
		||||
				allErrs = append(allErrs, field.Forbidden(idxPath.Child("readinessProbe"), "may not be set for init containers"))
 | 
			
		||||
			}
 | 
			
		||||
			if ctr.StartupProbe != nil {
 | 
			
		||||
				allErrs = append(allErrs, field.Forbidden(idxPath.Child("startupProbe"), "may not be set for init containers"))
 | 
			
		||||
				allErrs = append(allErrs, field.Forbidden(idxPath.Child("startupProbe"), "may not be set for init containers without restartPolicy=Always"))
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -3353,10 +3363,7 @@ func validateContainers(containers []core.Container, volumes map[string]core.Vol
 | 
			
		||||
		if ctr.ReadinessProbe != nil && ctr.ReadinessProbe.TerminationGracePeriodSeconds != nil {
 | 
			
		||||
			allErrs = append(allErrs, field.Invalid(path.Child("readinessProbe", "terminationGracePeriodSeconds"), ctr.ReadinessProbe.TerminationGracePeriodSeconds, "must not be set for readinessProbes"))
 | 
			
		||||
		}
 | 
			
		||||
		allErrs = append(allErrs, validateProbe(ctr.StartupProbe, path.Child("startupProbe"))...)
 | 
			
		||||
		if ctr.StartupProbe != nil && ctr.StartupProbe.SuccessThreshold != 1 {
 | 
			
		||||
			allErrs = append(allErrs, field.Invalid(path.Child("startupProbe", "successThreshold"), ctr.StartupProbe.SuccessThreshold, "must be 1"))
 | 
			
		||||
		}
 | 
			
		||||
		allErrs = append(allErrs, validateStartupProbe(ctr.StartupProbe, path.Child("startupProbe"))...)
 | 
			
		||||
 | 
			
		||||
		// These fields are disallowed for regular containers
 | 
			
		||||
		if ctr.RestartPolicy != nil {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user