From 93a19fce28b2fb0d38415149b2d40f70a2a042f3 Mon Sep 17 00:00:00 2001 From: Chakri Nelluri Date: Tue, 7 Aug 2018 16:33:24 -0400 Subject: [PATCH] Ignore EIO error in unmount path --- pkg/volume/flexvolume/detacher.go | 15 +++++++++++---- pkg/volume/flexvolume/unmounter.go | 9 ++++++--- pkg/volume/util/util.go | 11 ++++++----- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/pkg/volume/flexvolume/detacher.go b/pkg/volume/flexvolume/detacher.go index c55ffbfa47..9111f52e6c 100644 --- a/pkg/volume/flexvolume/detacher.go +++ b/pkg/volume/flexvolume/detacher.go @@ -49,17 +49,24 @@ func (d *flexVolumeDetacher) Detach(volumeName string, hostName types.NodeName) // UnmountDevice is part of the volume.Detacher interface. func (d *flexVolumeDetacher) UnmountDevice(deviceMountPath string) error { - if pathExists, pathErr := util.PathExists(deviceMountPath); pathErr != nil { - return fmt.Errorf("Error checking if path exists: %v", pathErr) - } else if !pathExists { + pathExists, pathErr := util.PathExists(deviceMountPath) + if !pathExists { glog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath) return nil } + if pathErr != nil && !util.IsCorruptedMnt(pathErr) { + return fmt.Errorf("Error checking path: %v", pathErr) + } notmnt, err := isNotMounted(d.plugin.host.GetMounter(d.plugin.GetPluginName()), deviceMountPath) if err != nil { - return err + if util.IsCorruptedMnt(err) { + notmnt = false // Corrupted error is assumed to be mounted. + } else { + return err + } } + if notmnt { glog.Warningf("Warning: Path: %v already unmounted", deviceMountPath) } else { diff --git a/pkg/volume/flexvolume/unmounter.go b/pkg/volume/flexvolume/unmounter.go index 64ff8e3983..67e26fe15c 100644 --- a/pkg/volume/flexvolume/unmounter.go +++ b/pkg/volume/flexvolume/unmounter.go @@ -44,13 +44,16 @@ func (f *flexVolumeUnmounter) TearDown() error { func (f *flexVolumeUnmounter) TearDownAt(dir string) error { - if pathExists, pathErr := util.PathExists(dir); pathErr != nil { - return fmt.Errorf("Error checking if path exists: %v", pathErr) - } else if !pathExists { + pathExists, pathErr := util.PathExists(dir) + if !pathExists { glog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) return nil } + if pathErr != nil && !util.IsCorruptedMnt(pathErr) { + return fmt.Errorf("Error checking path: %v", pathErr) + } + call := f.plugin.NewDriverCall(unmountCmd) call.Append(dir) _, err := call.Run() diff --git a/pkg/volume/util/util.go b/pkg/volume/util/util.go index 6737af4f40..d58f145caf 100644 --- a/pkg/volume/util/util.go +++ b/pkg/volume/util/util.go @@ -142,7 +142,7 @@ func UnmountMountPoint(mountPath string, mounter mount.Interface, extensiveMount glog.Warningf("Warning: Unmount skipped because path does not exist: %v", mountPath) return nil } - corruptedMnt := isCorruptedMnt(pathErr) + corruptedMnt := IsCorruptedMnt(pathErr) if pathErr != nil && !corruptedMnt { return fmt.Errorf("Error checking path: %v", pathErr) } @@ -198,15 +198,15 @@ func PathExists(path string) (bool, error) { return true, nil } else if os.IsNotExist(err) { return false, nil - } else if isCorruptedMnt(err) { + } else if IsCorruptedMnt(err) { return true, err } else { return false, err } } -// isCorruptedMnt return true if err is about corrupted mount point -func isCorruptedMnt(err error) bool { +// IsCorruptedMnt return true if err is about corrupted mount point +func IsCorruptedMnt(err error) bool { if err == nil { return false } @@ -221,7 +221,8 @@ func isCorruptedMnt(err error) bool { case *os.SyscallError: underlyingError = pe.Err } - return underlyingError == syscall.ENOTCONN || underlyingError == syscall.ESTALE + + return underlyingError == syscall.ENOTCONN || underlyingError == syscall.ESTALE || underlyingError == syscall.EIO } // GetSecretForPod locates secret by name in the pod's namespace and returns secret map