Remove validation for Capacity as it got moved from Spec to Status.
Also fix breakage from ExternalID validation: Default ExternalID to node name when not specified.
This commit is contained in:
@@ -942,21 +942,8 @@ func ValidateReadOnlyPersistentDisks(volumes []api.Volume) errs.ValidationErrorL
|
||||
func ValidateMinion(node *api.Node) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, ValidateObjectMeta(&node.ObjectMeta, false, ValidateNodeName).Prefix("metadata")...)
|
||||
// Capacity is required. Within capacity, memory and cpu resources are required.
|
||||
if len(node.Status.Capacity) == 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldRequired("status.Capacity"))
|
||||
} else {
|
||||
if val, ok := node.Status.Capacity[api.ResourceMemory]; !ok {
|
||||
allErrs = append(allErrs, errs.NewFieldRequired("status.Capacity[memory]"))
|
||||
} else if val.Value() < 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("status.Capacity[memory]", val, "memory capacity cannot be negative"))
|
||||
}
|
||||
if val, ok := node.Status.Capacity[api.ResourceCPU]; !ok {
|
||||
allErrs = append(allErrs, errs.NewFieldRequired("status.Capacity[cpu]"))
|
||||
} else if val.Value() < 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("status.Capacity[cpu]", val, "cpu capacity cannot be negative"))
|
||||
}
|
||||
}
|
||||
|
||||
// Only validate spec. All status fields are optional and can be updated later.
|
||||
|
||||
// external ID is required.
|
||||
if len(node.Spec.ExternalID) == 0 {
|
||||
|
Reference in New Issue
Block a user