mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-01-17 18:29:30 +00:00
rbd: use os.Remove to remove directory
using os.RemoveAll will remove everything
in the director after the Umount we should
be using os.Remove only to remove the empty
directory
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit 39cc628adf
)
This commit is contained in:
parent
640d1b9e79
commit
492c89ff07
@ -462,16 +462,7 @@ func (ns *NodeServer) NodePublishVolume(
|
||||
volOptions := &store.VolumeOptions{}
|
||||
defer volOptions.Destroy()
|
||||
|
||||
if err := volOptions.DetectMounter(req.GetVolumeContext()); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to detect mounter for volume %s: %v", volID, err.Error())
|
||||
}
|
||||
|
||||
volMounter, err := mounter.New(volOptions)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to create mounter for volume %s: %v", volID, err.Error())
|
||||
}
|
||||
|
||||
if err = util.CreateMountPoint(targetPath); err != nil {
|
||||
if err := util.CreateMountPoint(targetPath); err != nil {
|
||||
log.ErrorLog(ctx, "failed to create mount point at %s: %v", targetPath, err)
|
||||
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
@ -559,16 +550,6 @@ func (ns *NodeServer) NodeUnpublishVolume(
|
||||
}
|
||||
|
||||
targetPath := req.GetTargetPath()
|
||||
volID := req.GetVolumeId()
|
||||
if acquired := ns.VolumeLocks.TryAcquire(targetPath); !acquired {
|
||||
log.ErrorLog(ctx, util.TargetPathOperationAlreadyExistsFmt, targetPath)
|
||||
|
||||
return nil, status.Errorf(codes.Aborted, util.TargetPathOperationAlreadyExistsFmt, targetPath)
|
||||
}
|
||||
defer ns.VolumeLocks.Release(targetPath)
|
||||
|
||||
// stop the health-checker that may have been started in NodeGetVolumeStats()
|
||||
ns.healthChecker.StopChecker(volID, targetPath)
|
||||
|
||||
isMnt, err := util.IsMountPoint(ns.Mounter, targetPath)
|
||||
if err != nil {
|
||||
|
@ -940,7 +940,7 @@ func (ns *NodeServer) NodeUnpublishVolume(
|
||||
return nil, status.Error(codes.NotFound, err.Error())
|
||||
}
|
||||
if !isMnt {
|
||||
if err = os.RemoveAll(targetPath); err != nil {
|
||||
if err = os.Remove(targetPath); err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
@ -951,7 +951,7 @@ func (ns *NodeServer) NodeUnpublishVolume(
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
if err = os.RemoveAll(targetPath); err != nil {
|
||||
if err = os.Remove(targetPath); err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user