Counting pod volume towards PV limit even if PV/PVC is missing

This commit is contained in:
Abhishek Gupta
2016-06-10 17:15:50 -07:00
parent 8bcecac12f
commit 07bc06ba50
2 changed files with 77 additions and 3 deletions

View File

@@ -1392,6 +1392,32 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
},
},
}
deletedPVCPod := &api.Pod{
Spec: api.PodSpec{
Volumes: []api.Volume{
{
VolumeSource: api.VolumeSource{
PersistentVolumeClaim: &api.PersistentVolumeClaimVolumeSource{
ClaimName: "deletedPVC",
},
},
},
},
},
}
deletedPVPod := &api.Pod{
Spec: api.PodSpec{
Volumes: []api.Volume{
{
VolumeSource: api.VolumeSource{
PersistentVolumeClaim: &api.PersistentVolumeClaimVolumeSource{
ClaimName: "deletedPV",
},
},
},
},
},
}
emptyPod := &api.Pod{
Spec: api.PodSpec{},
}
@@ -1466,6 +1492,34 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
fits: true,
test: "the same EBS volumes are not counted multiple times",
},
{
newPod: ebsPVCPod,
existingPods: []*api.Pod{oneVolPod, deletedPVCPod},
maxVols: 2,
fits: false,
test: "pod with missing PVC is counted towards the PV limit",
},
{
newPod: ebsPVCPod,
existingPods: []*api.Pod{oneVolPod, deletedPVCPod},
maxVols: 3,
fits: true,
test: "pod with missing PVC is counted towards the PV limit",
},
{
newPod: ebsPVCPod,
existingPods: []*api.Pod{oneVolPod, deletedPVPod},
maxVols: 2,
fits: false,
test: "pod with missing PV is counted towards the PV limit",
},
{
newPod: ebsPVCPod,
existingPods: []*api.Pod{oneVolPod, deletedPVPod},
maxVols: 3,
fits: true,
test: "pod with missing PV is counted towards the PV limit",
},
}
pvInfo := FakePersistentVolumeInfo{
@@ -1473,7 +1527,7 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "someEBSVol"},
Spec: api.PersistentVolumeSpec{
PersistentVolumeSource: api.PersistentVolumeSource{
AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{},
AWSElasticBlockStore: &api.AWSElasticBlockStoreVolumeSource{VolumeID: "ebsVol"},
},
},
},
@@ -1494,6 +1548,10 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "someNonEBSVol"},
Spec: api.PersistentVolumeClaimSpec{VolumeName: "someNonEBSVol"},
},
{
ObjectMeta: api.ObjectMeta{Name: "deletedPV"},
Spec: api.PersistentVolumeClaimSpec{VolumeName: "deletedPV"},
},
}
filter := VolumeFilter{