Validate that PV capacity and PVC capacity requests are greater than zero
This commit is contained in:
@@ -260,6 +260,21 @@ func TestValidatePersistentVolumes(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
},
|
||||
"bad-volume-zero-capacity": {
|
||||
isExpectedFailure: true,
|
||||
volume: testVolume("foo", "", core.PersistentVolumeSpec{
|
||||
Capacity: core.ResourceList{
|
||||
core.ResourceName(core.ResourceStorage): resource.MustParse("0"),
|
||||
},
|
||||
AccessModes: []core.PersistentVolumeAccessMode{core.ReadWriteOnce},
|
||||
PersistentVolumeSource: core.PersistentVolumeSource{
|
||||
HostPath: &core.HostPathVolumeSource{
|
||||
Path: "/foo",
|
||||
Type: newHostPathType(string(core.HostPathDirectory)),
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
"missing-accessmodes": {
|
||||
isExpectedFailure: true,
|
||||
volume: testVolume("goodname", "missing-accessmodes", core.PersistentVolumeSpec{
|
||||
@@ -732,6 +747,29 @@ func TestValidatePersistentVolumeClaim(t *testing.T) {
|
||||
StorageClassName: &validClassName,
|
||||
}),
|
||||
},
|
||||
"invalid-claim-zero-capacity": {
|
||||
isExpectedFailure: true,
|
||||
claim: testVolumeClaim("foo", "ns", core.PersistentVolumeClaimSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
||||
{
|
||||
Key: "key2",
|
||||
Operator: "Exists",
|
||||
},
|
||||
},
|
||||
},
|
||||
AccessModes: []core.PersistentVolumeAccessMode{
|
||||
core.ReadWriteOnce,
|
||||
core.ReadOnlyMany,
|
||||
},
|
||||
Resources: core.ResourceRequirements{
|
||||
Requests: core.ResourceList{
|
||||
core.ResourceName(core.ResourceStorage): resource.MustParse("0G"),
|
||||
},
|
||||
},
|
||||
StorageClassName: &validClassName,
|
||||
}),
|
||||
},
|
||||
"invalid-label-selector": {
|
||||
isExpectedFailure: true,
|
||||
claim: testVolumeClaim("foo", "ns", core.PersistentVolumeClaimSpec{
|
||||
|
Reference in New Issue
Block a user