rbd: Bail out from nodeexpansion if its block mode pvc

At CSI spec < 1.2.0, there was no volumecapability in the
expand request. However its available from v1.2+ which allows
us to declare the node operations based on the volume mode.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2020-08-17 13:10:05 +05:30
committed by mergify[bot]
parent e9d5e731dc
commit 1f5b84745f
2 changed files with 6 additions and 17 deletions

View File

@ -1050,6 +1050,12 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
return nil, status.Error(codes.InvalidArgument, "capacityRange cannot be empty")
}
nodeExpansion := false
// Get the nodeexpansion flag set based on the volume mode
if req.GetVolumeCapability().GetBlock() == nil {
nodeExpansion = true
}
// lock out parallel requests against the same volume ID
if acquired := cs.VolumeLocks.TryAcquire(volID); !acquired {
klog.Errorf(util.Log(ctx, util.VolumeOperationAlreadyExistsFmt), volID)
@ -1097,7 +1103,6 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
volSize := util.RoundOffBytes(req.GetCapacityRange().GetRequiredBytes())
// resize volume if required
nodeExpansion := false
if rbdVol.VolSize < volSize {
util.DebugLog(ctx, "rbd volume %s size is %v,resizing to %v", rbdVol, rbdVol.VolSize, volSize)
err = rbdVol.resize(volSize)
@ -1105,7 +1110,6 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
klog.Errorf(util.Log(ctx, "failed to resize rbd image: %s with error: %v"), rbdVol, err)
return nil, status.Error(codes.Internal, err.Error())
}
nodeExpansion = true
}
return &csi.ControllerExpandVolumeResponse{