Ignore EIO error in unmount path

pull/8/head
Chakri Nelluri 2018-08-07 16:33:24 -04:00 committed by Chakravarthy Nelluri
parent f8b6c59494
commit 93a19fce28
3 changed files with 23 additions and 12 deletions

View File

@ -49,17 +49,24 @@ func (d *flexVolumeDetacher) Detach(volumeName string, hostName types.NodeName)
// UnmountDevice is part of the volume.Detacher interface. // UnmountDevice is part of the volume.Detacher interface.
func (d *flexVolumeDetacher) UnmountDevice(deviceMountPath string) error { func (d *flexVolumeDetacher) UnmountDevice(deviceMountPath string) error {
if pathExists, pathErr := util.PathExists(deviceMountPath); pathErr != nil { pathExists, pathErr := util.PathExists(deviceMountPath)
return fmt.Errorf("Error checking if path exists: %v", pathErr) if !pathExists {
} else if !pathExists {
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath) glog.Warningf("Warning: Unmount skipped because path does not exist: %v", deviceMountPath)
return nil 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) notmnt, err := isNotMounted(d.plugin.host.GetMounter(d.plugin.GetPluginName()), deviceMountPath)
if err != nil { if err != nil {
return err if util.IsCorruptedMnt(err) {
notmnt = false // Corrupted error is assumed to be mounted.
} else {
return err
}
} }
if notmnt { if notmnt {
glog.Warningf("Warning: Path: %v already unmounted", deviceMountPath) glog.Warningf("Warning: Path: %v already unmounted", deviceMountPath)
} else { } else {

View File

@ -44,13 +44,16 @@ func (f *flexVolumeUnmounter) TearDown() error {
func (f *flexVolumeUnmounter) TearDownAt(dir string) error { func (f *flexVolumeUnmounter) TearDownAt(dir string) error {
if pathExists, pathErr := util.PathExists(dir); pathErr != nil { pathExists, pathErr := util.PathExists(dir)
return fmt.Errorf("Error checking if path exists: %v", pathErr) if !pathExists {
} else if !pathExists {
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir) glog.Warningf("Warning: Unmount skipped because path does not exist: %v", dir)
return nil return nil
} }
if pathErr != nil && !util.IsCorruptedMnt(pathErr) {
return fmt.Errorf("Error checking path: %v", pathErr)
}
call := f.plugin.NewDriverCall(unmountCmd) call := f.plugin.NewDriverCall(unmountCmd)
call.Append(dir) call.Append(dir)
_, err := call.Run() _, err := call.Run()

View File

@ -142,7 +142,7 @@ func UnmountMountPoint(mountPath string, mounter mount.Interface, extensiveMount
glog.Warningf("Warning: Unmount skipped because path does not exist: %v", mountPath) glog.Warningf("Warning: Unmount skipped because path does not exist: %v", mountPath)
return nil return nil
} }
corruptedMnt := isCorruptedMnt(pathErr) corruptedMnt := IsCorruptedMnt(pathErr)
if pathErr != nil && !corruptedMnt { if pathErr != nil && !corruptedMnt {
return fmt.Errorf("Error checking path: %v", pathErr) return fmt.Errorf("Error checking path: %v", pathErr)
} }
@ -198,15 +198,15 @@ func PathExists(path string) (bool, error) {
return true, nil return true, nil
} else if os.IsNotExist(err) { } else if os.IsNotExist(err) {
return false, nil return false, nil
} else if isCorruptedMnt(err) { } else if IsCorruptedMnt(err) {
return true, err return true, err
} else { } else {
return false, err return false, err
} }
} }
// isCorruptedMnt return true if err is about corrupted mount point // IsCorruptedMnt return true if err is about corrupted mount point
func isCorruptedMnt(err error) bool { func IsCorruptedMnt(err error) bool {
if err == nil { if err == nil {
return false return false
} }
@ -221,7 +221,8 @@ func isCorruptedMnt(err error) bool {
case *os.SyscallError: case *os.SyscallError:
underlyingError = pe.Err 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 // GetSecretForPod locates secret by name in the pod's namespace and returns secret map