mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
loosened validation on pvc limitranger
This commit is contained in:
parent
6bda989d54
commit
a3f4d8a506
@ -3010,11 +3010,8 @@ func ValidateLimitRange(limitRange *api.LimitRange) field.ErrorList {
|
||||
if limit.Type == api.LimitTypePersistentVolumeClaim {
|
||||
_, minQuantityFound := limit.Min[api.ResourceStorage]
|
||||
_, maxQuantityFound := limit.Max[api.ResourceStorage]
|
||||
if !minQuantityFound {
|
||||
allErrs = append(allErrs, field.Required(idxPath.Child("min"), "minimum storage value is required"))
|
||||
}
|
||||
if !maxQuantityFound {
|
||||
allErrs = append(allErrs, field.Required(idxPath.Child("max"), "maximum storage value is required"))
|
||||
if !minQuantityFound && !maxQuantityFound {
|
||||
allErrs = append(allErrs, field.Required(idxPath.Child("limits"), "either minimum or maximum storage value is required, but neither was provided"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6627,6 +6627,28 @@ func TestValidateLimitRange(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "pvc-min-only",
|
||||
spec: api.LimitRangeSpec{
|
||||
Limits: []api.LimitRangeItem{
|
||||
{
|
||||
Type: api.LimitTypePersistentVolumeClaim,
|
||||
Min: getStorageResourceList("5Gi"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "pvc-max-only",
|
||||
spec: api.LimitRangeSpec{
|
||||
Limits: []api.LimitRangeItem{
|
||||
{
|
||||
Type: api.LimitTypePersistentVolumeClaim,
|
||||
Max: getStorageResourceList("10Gi"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "all-fields-valid-big-numbers",
|
||||
spec: api.LimitRangeSpec{
|
||||
@ -6834,27 +6856,15 @@ func TestValidateLimitRange(t *testing.T) {
|
||||
}},
|
||||
"must be a standard limit type or fully qualified",
|
||||
},
|
||||
"invalid missing required min field": {
|
||||
"min and max values missing, one required": {
|
||||
api.LimitRange{ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: "foo"}, Spec: api.LimitRangeSpec{
|
||||
Limits: []api.LimitRangeItem{
|
||||
{
|
||||
Type: api.LimitTypePersistentVolumeClaim,
|
||||
Max: getStorageResourceList("10000T"),
|
||||
},
|
||||
},
|
||||
}},
|
||||
"minimum storage value is required",
|
||||
},
|
||||
"invalid missing required max field": {
|
||||
api.LimitRange{ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: "foo"}, Spec: api.LimitRangeSpec{
|
||||
Limits: []api.LimitRangeItem{
|
||||
{
|
||||
Type: api.LimitTypePersistentVolumeClaim,
|
||||
Min: getStorageResourceList("10000T"),
|
||||
},
|
||||
},
|
||||
}},
|
||||
"maximum storage value is required",
|
||||
"either minimum or maximum storage value is required, but neither was provided",
|
||||
},
|
||||
"invalid min greater than max": {
|
||||
api.LimitRange{ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: "foo"}, Spec: api.LimitRangeSpec{
|
||||
|
Loading…
Reference in New Issue
Block a user