From 33944323719c220130ff3baec5dcbdcdbd87bf8b Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Wed, 18 Dec 2019 14:02:53 +0530 Subject: [PATCH] Fix block resize issue in RBD For the filesystem resize the stagingPath will be passed to NodeExpandVolume and for the block resize the targetpath will be passed. Added code to handle resize for both block and file system resize Signed-off-by: Madhu Rajanna --- pkg/rbd/nodeserver.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/rbd/nodeserver.go b/pkg/rbd/nodeserver.go index 454660e1b..7f2e1a9b8 100644 --- a/pkg/rbd/nodeserver.go +++ b/pkg/rbd/nodeserver.go @@ -543,6 +543,20 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } + // 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 + } imgInfo, devicePath, err := getDevicePathAndImageInfo(ctx, volumePath) if err != nil { return nil, status.Error(codes.Internal, err.Error())