mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #114736 from andyzhangx/fix-tryUnmount
fix: tryUnmount should respect mounter.withSafeNotMountedBehavior
This commit is contained in:
commit
4e70155dbd
@ -383,7 +383,7 @@ func (mounter *Mounter) Unmount(target string) error {
|
||||
// UnmountWithForce unmounts given target but will retry unmounting with force option
|
||||
// after given timeout.
|
||||
func (mounter *Mounter) UnmountWithForce(target string, umountTimeout time.Duration) error {
|
||||
err := tryUnmount(target, umountTimeout)
|
||||
err := tryUnmount(mounter, target, umountTimeout)
|
||||
if err != nil {
|
||||
if err == context.DeadlineExceeded {
|
||||
klog.V(2).Infof("Timed out waiting for unmount of %s, trying with -f", target)
|
||||
@ -775,7 +775,7 @@ func (mounter *Mounter) IsMountPoint(file string) (bool, error) {
|
||||
}
|
||||
|
||||
// tryUnmount calls plain "umount" and waits for unmountTimeout for it to finish.
|
||||
func tryUnmount(path string, unmountTimeout time.Duration) error {
|
||||
func tryUnmount(mounter *Mounter, path string, unmountTimeout time.Duration) error {
|
||||
klog.V(4).Infof("Unmounting %s", path)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), unmountTimeout)
|
||||
defer cancel()
|
||||
@ -790,6 +790,10 @@ func tryUnmount(path string, unmountTimeout time.Duration) error {
|
||||
}
|
||||
|
||||
if cmderr != nil {
|
||||
if mounter.withSafeNotMountedBehavior && strings.Contains(string(out), errNotMounted) {
|
||||
klog.V(4).Infof("ignoring 'not mounted' error for %s", path)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unmount failed: %v\nUnmounting arguments: %s\nOutput: %s", cmderr, path, string(out))
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user