Change SizeLimit to a pointer

This PR fixes issue #50121
This commit is contained in:
Jing Xu
2017-08-04 11:50:38 -07:00
parent ad6c85ca2e
commit 4d6da1fd9a
8 changed files with 15 additions and 11 deletions

View File

@@ -386,10 +386,13 @@ func validateVolumeSource(source *api.VolumeSource, fldPath *field.Path, volName
if source.EmptyDir != nil {
numVolumes++
if !utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolation) {
unsetSizeLimit := resource.Quantity{}
if unsetSizeLimit.Cmp(source.EmptyDir.SizeLimit) != 0 {
if source.EmptyDir.SizeLimit != nil && source.EmptyDir.SizeLimit.Cmp(resource.Quantity{}) != 0 {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("emptyDir").Child("sizeLimit"), "SizeLimit field disabled by feature-gate for EmptyDir volumes"))
}
} else {
if source.EmptyDir.SizeLimit != nil && source.EmptyDir.SizeLimit.Cmp(resource.Quantity{}) < 0 {
allErrs = append(allErrs, field.Forbidden(fldPath.Child("emptyDir").Child("sizeLimit"), "SizeLimit field must be a valid resource quantity"))
}
}
}
if source.HostPath != nil {