add memory validation on API level for memory negative values
@@ -321,6 +321,17 @@ func validateVirtualMachineSpec(field *k8sfield.Path, spec *v1.VirtualMachineSpe
return causes
}
+ // Validate requested memory size if value is not negative
+ if spec.Domain.Resources.Requests.Memory().Value() < 0 {
+ causes = append(causes, metav1.StatusCause{
+ Type: metav1.CauseTypeFieldValueInvalid,
+ Message: fmt.Sprintf("%s is specified as negative value", field.Child("domain", "resources", "requests", "memory").String()),
+ Field: field.Child("domain", "resources", "requests", "memory").String(),
+ })
+ // We won't process anything with requested negative memory size
+ return causes
+ }
+
for _, volume := range spec.Volumes {
volumeNameMap[volume.Name] = &volume
}
