From fe817674abac9a7a2a8ac53d9f2debae9c9d36be Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Tue, 16 Aug 2016 12:24:18 -0400 Subject: [PATCH] Don't bind pre-bound pvc & pv if size request not satisfied --- pkg/controller/volume/persistentvolume/index.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/controller/volume/persistentvolume/index.go b/pkg/controller/volume/persistentvolume/index.go index 60699e6e653..55610721d9c 100644 --- a/pkg/controller/volume/persistentvolume/index.go +++ b/pkg/controller/volume/persistentvolume/index.go @@ -117,9 +117,14 @@ func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *api.PersistentVo // the claim. for _, volume := range volumes { if isVolumeBoundToClaim(volume, claim) { - // this claim and volume are bound; return it, - // whether the claim is prebound or for volumes - // intended for dynamic provisioning v1 + // this claim and volume are pre-bound; return + // the volume if the size request is satisfied, + // otherwise leave the claim pending + volumeQty := volume.Spec.Capacity[api.ResourceStorage] + volumeSize := volumeQty.Value() + if volumeSize < requestedSize { + return nil, nil + } return volume, nil }