mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
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:
parent
e9d5e731dc
commit
1f5b84745f
@ -1050,6 +1050,12 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
|
|||||||
return nil, status.Error(codes.InvalidArgument, "capacityRange cannot be empty")
|
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
|
// lock out parallel requests against the same volume ID
|
||||||
if acquired := cs.VolumeLocks.TryAcquire(volID); !acquired {
|
if acquired := cs.VolumeLocks.TryAcquire(volID); !acquired {
|
||||||
klog.Errorf(util.Log(ctx, util.VolumeOperationAlreadyExistsFmt), volID)
|
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())
|
volSize := util.RoundOffBytes(req.GetCapacityRange().GetRequiredBytes())
|
||||||
|
|
||||||
// resize volume if required
|
// resize volume if required
|
||||||
nodeExpansion := false
|
|
||||||
if rbdVol.VolSize < volSize {
|
if rbdVol.VolSize < volSize {
|
||||||
util.DebugLog(ctx, "rbd volume %s size is %v,resizing to %v", rbdVol, rbdVol.VolSize, volSize)
|
util.DebugLog(ctx, "rbd volume %s size is %v,resizing to %v", rbdVol, rbdVol.VolSize, volSize)
|
||||||
err = rbdVol.resize(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)
|
klog.Errorf(util.Log(ctx, "failed to resize rbd image: %s with error: %v"), rbdVol, err)
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
}
|
}
|
||||||
nodeExpansion = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &csi.ControllerExpandVolumeResponse{
|
return &csi.ControllerExpandVolumeResponse{
|
||||||
|
@ -715,21 +715,6 @@ func (ns *NodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV
|
|||||||
}
|
}
|
||||||
defer ns.VolumeLocks.Release(volumeID)
|
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)
|
devicePath, err := getDevicePath(ctx, volumePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Error(codes.Internal, err.Error())
|
return nil, status.Error(codes.Internal, err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user