mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-12 21:40:29 +00:00
Downward API hugepages
This commit is contained in:
@@ -91,10 +91,7 @@ func (podStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
|
||||
// Validate validates a new pod.
|
||||
func (podStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
pod := obj.(*api.Pod)
|
||||
opts := validation.PodValidationOptions{
|
||||
// Allow multiple huge pages on pod create if feature is enabled
|
||||
AllowMultipleHugePageResources: utilfeature.DefaultFeatureGate.Enabled(features.HugePageStorageMediumSize),
|
||||
}
|
||||
opts := podutil.GetValidationOptionsFromPodSpec(&pod.Spec, nil)
|
||||
return validation.ValidatePodCreate(pod, opts)
|
||||
}
|
||||
|
||||
@@ -109,11 +106,10 @@ func (podStrategy) AllowCreateOnUpdate() bool {
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (podStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
oldFailsSingleHugepagesValidation := len(validation.ValidatePodSingleHugePageResources(old.(*api.Pod), field.NewPath("spec"))) > 0
|
||||
opts := validation.PodValidationOptions{
|
||||
// Allow multiple huge pages on pod create if feature is enabled or if the old pod already has multiple hugepages specified
|
||||
AllowMultipleHugePageResources: oldFailsSingleHugepagesValidation || utilfeature.DefaultFeatureGate.Enabled(features.HugePageStorageMediumSize),
|
||||
}
|
||||
// Allow downward api usage of hugepages on pod update if feature is enabled or if the old pod already had used them.
|
||||
pod := obj.(*api.Pod)
|
||||
oldPod := old.(*api.Pod)
|
||||
opts := podutil.GetValidationOptionsFromPodSpec(&pod.Spec, &oldPod.Spec)
|
||||
return validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod), opts)
|
||||
}
|
||||
|
||||
@@ -182,7 +178,10 @@ type podEphemeralContainersStrategy struct {
|
||||
var EphemeralContainersStrategy = podEphemeralContainersStrategy{Strategy}
|
||||
|
||||
func (podEphemeralContainersStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
return validation.ValidatePodEphemeralContainersUpdate(obj.(*api.Pod), old.(*api.Pod))
|
||||
newPod := obj.(*api.Pod)
|
||||
oldPod := old.(*api.Pod)
|
||||
opts := podutil.GetValidationOptionsFromPodSpec(&newPod.Spec, &oldPod.Spec)
|
||||
return validation.ValidatePodEphemeralContainersUpdate(newPod, oldPod, opts)
|
||||
}
|
||||
|
||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||
|
||||
@@ -53,7 +53,8 @@ func (podTemplateStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obj
|
||||
// Validate validates a new pod template.
|
||||
func (podTemplateStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
template := obj.(*api.PodTemplate)
|
||||
return corevalidation.ValidatePodTemplate(template)
|
||||
opts := pod.GetValidationOptionsFromPodTemplate(&template.Template, nil)
|
||||
return corevalidation.ValidatePodTemplate(template, opts)
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
@@ -77,7 +78,10 @@ func (podTemplateStrategy) PrepareForUpdate(ctx context.Context, obj, old runtim
|
||||
func (podTemplateStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
template := obj.(*api.PodTemplate)
|
||||
oldTemplate := old.(*api.PodTemplate)
|
||||
return corevalidation.ValidatePodTemplateUpdate(template, oldTemplate)
|
||||
|
||||
// Allow downward api usage of hugepages on pod update if feature is enabled or if the old pod already had used them.
|
||||
opts := pod.GetValidationOptionsFromPodTemplate(&template.Template, &oldTemplate.Template)
|
||||
return corevalidation.ValidatePodTemplateUpdate(template, oldTemplate, opts)
|
||||
}
|
||||
|
||||
func (podTemplateStrategy) AllowUnconditionalUpdate() bool {
|
||||
|
||||
@@ -108,7 +108,8 @@ func (rcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
|
||||
// Validate validates a new replication controller.
|
||||
func (rcStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
controller := obj.(*api.ReplicationController)
|
||||
return validation.ValidateReplicationController(controller)
|
||||
opts := pod.GetValidationOptionsFromPodTemplate(controller.Spec.Template, nil)
|
||||
return validation.ValidateReplicationController(controller, opts)
|
||||
}
|
||||
|
||||
// Canonicalize normalizes the object after validation.
|
||||
@@ -126,8 +127,9 @@ func (rcStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) f
|
||||
oldRc := old.(*api.ReplicationController)
|
||||
newRc := obj.(*api.ReplicationController)
|
||||
|
||||
validationErrorList := validation.ValidateReplicationController(newRc)
|
||||
updateErrorList := validation.ValidateReplicationControllerUpdate(newRc, oldRc)
|
||||
opts := pod.GetValidationOptionsFromPodTemplate(newRc.Spec.Template, oldRc.Spec.Template)
|
||||
validationErrorList := validation.ValidateReplicationController(newRc, opts)
|
||||
updateErrorList := validation.ValidateReplicationControllerUpdate(newRc, oldRc, opts)
|
||||
errs := append(validationErrorList, updateErrorList...)
|
||||
|
||||
for key, value := range helper.NonConvertibleFields(oldRc.Annotations) {
|
||||
|
||||
Reference in New Issue
Block a user