mirror of https://github.com/k3s-io/k3s
Ignore EIO error in unmount path
parent
f8b6c59494
commit
93a19fce28
|
@ -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 {
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue