From 14a2671d086ea57c02a950b02e4948c521e7c395 Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Mon, 22 Jan 2018 21:07:19 +0530 Subject: [PATCH] Make ExpandVolumeDevice() idempotent if existing volume capacity meets the requested size. Signed-off-by: Humble Chirammal --- pkg/volume/glusterfs/glusterfs.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index 8f2618c765d..786c957b1f5 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -1132,6 +1132,21 @@ func (plugin *glusterfsPlugin) ExpandVolumeDevice(spec *volume.Spec, newSize res expansionSize := (newSize.Value() - oldSize.Value()) expansionSizeGiB := int(volume.RoundUpSize(expansionSize, volume.GIB)) + // Find out requested Size + + requestGiB := volume.RoundUpToGiB(newSize) + + //Check the existing volume size + currentVolumeInfo, err := cli.VolumeInfo(volumeID) + if err != nil { + glog.Errorf("error when fetching details of volume :%v", err) + return oldSize, err + } + + if int64(currentVolumeInfo.Size) >= requestGiB { + return newSize, nil + } + // Make volume expansion request volumeExpandReq := &gapi.VolumeExpandRequest{Size: expansionSizeGiB}