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 00d252e4ac)
This commit is contained in:
Madhu Rajanna 2024-11-20 10:15:40 +01:00 committed by mergify[bot]
parent b939471ac2
commit 590955ea76

View File

@ -938,7 +938,7 @@ func (ns *NodeServer) NodeUnpublishVolume(
return nil, status.Error(codes.NotFound, err.Error()) return nil, status.Error(codes.NotFound, err.Error())
} }
if !isMnt { if !isMnt {
if err = os.RemoveAll(targetPath); err != nil { if err = os.Remove(targetPath); err != nil {
return nil, status.Error(codes.Internal, err.Error()) return nil, status.Error(codes.Internal, err.Error())
} }
@ -949,7 +949,7 @@ func (ns *NodeServer) NodeUnpublishVolume(
return nil, status.Error(codes.Internal, err.Error()) 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()) return nil, status.Error(codes.Internal, err.Error())
} }