mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
Merge pull request #31034 from jingxu97/unmount-8-19
Automatic merge from submit-queue Add ismounted check in unmountpath function This change is to fix PR #30930. The function should check if the mountpath is still mounted or not. If it is not, it should continue with removing the directory instead of returning error.
This commit is contained in:
commit
d0cca393d7
@ -73,14 +73,28 @@ func UnmountPath(mountPath string, mounter mount.Interface) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
err := mounter.Unmount(mountPath)
|
||||
if err == nil {
|
||||
// Only delete directory on successful unmount
|
||||
glog.V(5).Infof("Unmounted %q. Deleting path.", mountPath)
|
||||
notMnt, err := mounter.IsLikelyNotMountPoint(mountPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if notMnt {
|
||||
glog.Warningf("Warning: %q is not a mountpoint, deleting", mountPath)
|
||||
return os.Remove(mountPath)
|
||||
}
|
||||
|
||||
return err
|
||||
// Unmount the mount path
|
||||
if err := mounter.Unmount(mountPath); err != nil {
|
||||
return err
|
||||
}
|
||||
notMnt, mntErr := mounter.IsLikelyNotMountPoint(mountPath)
|
||||
if mntErr != nil {
|
||||
return err
|
||||
}
|
||||
if notMnt {
|
||||
glog.V(4).Info("%q is unmounted, deleting the directory", mountPath)
|
||||
return os.Remove(mountPath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// PathExists returns true if the specified path exists.
|
||||
|
Loading…
Reference in New Issue
Block a user