mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Add AllowSidecarResizePolicy to relax resize policy validation check of sidecar containers
This commit is contained in:
@@ -416,6 +416,8 @@ func GetValidationOptionsFromPodSpecAndMeta(podSpec, oldPodSpec *api.PodSpec, po
|
||||
}
|
||||
|
||||
opts.AllowPodLifecycleSleepActionZeroValue = opts.AllowPodLifecycleSleepActionZeroValue || podLifecycleSleepActionZeroValueInUse(podSpec)
|
||||
// If oldPod has resize policy set on the restartable init container, we must allow it
|
||||
opts.AllowSidecarResizePolicy = hasRestartableInitContainerResizePolicy(oldPodSpec)
|
||||
}
|
||||
if oldPodMeta != nil && !opts.AllowInvalidPodDeletionCost {
|
||||
// This is an update, so validate only if the existing object was valid.
|
||||
@@ -1373,3 +1375,17 @@ func useOnlyRecursiveSELinuxChangePolicy(oldPodSpec *api.PodSpec) bool {
|
||||
// No feature gate + no value in the old object -> only Recursive is allowed
|
||||
return true
|
||||
}
|
||||
|
||||
// hasRestartableInitContainerResizePolicy returns true if the pod spec is non-nil and
|
||||
// it has any init container with ContainerRestartPolicyAlways and non-nil ResizePolicy.
|
||||
func hasRestartableInitContainerResizePolicy(podSpec *api.PodSpec) bool {
|
||||
if podSpec == nil {
|
||||
return false
|
||||
}
|
||||
for _, c := range podSpec.InitContainers {
|
||||
if IsRestartableInitContainer(&c) && len(c.ResizePolicy) > 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user