Merge pull request #21865 from piosz/cluster-autoscaling-cleanup
Cluster autoscaling cleanup
This commit is contained in:
@@ -648,43 +648,6 @@ func validateIngressBackend(backend *extensions.IngressBackend, fldPath *field.P
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateClusterAutoscalerSpec(spec extensions.ClusterAutoscalerSpec, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if spec.MinNodes < 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("minNodes"), spec.MinNodes, "must be greater than or equal to 0"))
|
||||
}
|
||||
if spec.MaxNodes < spec.MinNodes {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("maxNodes"), spec.MaxNodes, "must be greater than or equal to `minNodes`"))
|
||||
}
|
||||
if len(spec.TargetUtilization) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetUtilization"), ""))
|
||||
}
|
||||
for _, target := range spec.TargetUtilization {
|
||||
if len(target.Resource) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("targetUtilization", "resource"), ""))
|
||||
}
|
||||
if target.Value <= 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetUtilization", "value"), target.Value, "must be greater than 0"))
|
||||
}
|
||||
if target.Value > 1 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("targetUtilization", "value"), target.Value, "must be less than or equal to 1"))
|
||||
}
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateClusterAutoscaler(autoscaler *extensions.ClusterAutoscaler) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if autoscaler.Name != "ClusterAutoscaler" {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata", "name"), autoscaler.Name, "must be 'ClusterAutoscaler'"))
|
||||
}
|
||||
if autoscaler.Namespace != api.NamespaceDefault {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("metadata", "namespace"), autoscaler.Namespace, "must be 'default'"))
|
||||
}
|
||||
allErrs = append(allErrs, validateClusterAutoscalerSpec(autoscaler.Spec, field.NewPath("spec"))...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateScale(scale *extensions.Scale) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&scale.ObjectMeta, true, apivalidation.NameIsDNSSubdomain, field.NewPath("metadata"))...)
|
||||
|
Reference in New Issue
Block a user