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())