From d04dbd081141c6b552e5e143a38c54f20b72600a Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Mon, 17 Aug 2020 13:10:05 +0530 Subject: [PATCH] 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 (cherry picked from commit 1f5b84745facc983936ed2004f2bedc802fcec20) --- internal/rbd/controllerserver.go | 8 ++++++-- internal/rbd/nodeserver.go | 15 --------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index d9945184b..d84ffaf4f 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -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{ diff --git a/internal/rbd/nodeserver.go b/internal/rbd/nodeserver.go index f4422335a..3615a3db0 100644 --- a/internal/rbd/nodeserver.go +++ b/internal/rbd/nodeserver.go @@ -715,21 +715,6 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV } defer ns.VolumeLocks.Release(volumeID) - // volumePath is targetPath for block PVC and stagingPath for filesystem. - // check the path is mountpoint or not, if it is - // mountpoint treat this as block PVC or else it is filesystem PVC - // TODO remove this once ceph-csi supports CSI v1.2.0 spec - notMnt, err := mount.IsNotMountPoint(ns.mounter, volumePath) - if err != nil { - if os.IsNotExist(err) { - return nil, status.Error(codes.NotFound, err.Error()) - } - return nil, status.Error(codes.Internal, err.Error()) - } - if !notMnt { - return &csi.NodeExpandVolumeResponse{}, nil - } - devicePath, err := getDevicePath(ctx, volumePath) if err != nil { return nil, status.Error(codes.Internal, err.Error())