mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
discard umount error if directory is not mounted
if the directory is not mounted return nil during umount of mountPoint Discard error if error is os.IsNotExist Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
b849b7daaa
commit
dcafdb519e
@ -266,7 +266,8 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
if err = os.Remove(targetPath); err != nil {
|
||||
err = os.Remove(targetPath)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
|
@ -321,6 +321,10 @@ func bindMount(ctx context.Context, from, to string, readOnly bool, mntOptions [
|
||||
|
||||
func unmountVolume(ctx context.Context, mountPoint string) error {
|
||||
if err := execCommandErr(ctx, "umount", mountPoint); err != nil {
|
||||
if strings.Contains(err.Error(), fmt.Sprintf("exit status 32: umount: %s: not mounted", mountPoint)) ||
|
||||
strings.Contains(err.Error(), "No such file or directory") {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ func (nc *NodeCache) Delete(identifier string) error {
|
||||
file := path.Join(nc.BasePath, nc.CacheDir, identifier+".json")
|
||||
err := os.Remove(file)
|
||||
if err != nil {
|
||||
if err == os.ErrNotExist {
|
||||
if os.IsNotExist(err) {
|
||||
klog.V(4).Infof("node-cache: cannot delete missing metadata storage file %s, assuming it's already deleted", file)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user