Make unmount device log warning and continue if mount path is not found

This commit is contained in:
Brian Pursley
2020-06-24 10:02:50 -04:00
parent 1faf097f3f
commit 4cc4e774c6

View File

@@ -835,8 +835,15 @@ func (og *operationGenerator) GenerateUnmountDeviceFunc(
deviceMountPath, err :=
volumeDeviceMounter.GetDeviceMountPath(deviceToDetach.VolumeSpec)
if err != nil {
// On failure, return error. Caller will log and retry.
return deviceToDetach.GenerateError("GetDeviceMountPath failed", err)
// On failure other than "does not exist", return error. Caller will log and retry.
if !strings.Contains(err.Error(), "does not exist") {
return deviceToDetach.GenerateError("GetDeviceMountPath failed", err)
}
// If the mount path could not be found, don't fail the unmount, but instead log a warning and proceed,
// using the value from deviceToDetach.DeviceMountPath, so that the device can be marked as unmounted
deviceMountPath = deviceToDetach.DeviceMountPath
klog.Warningf(deviceToDetach.GenerateMsg(fmt.Sprintf(
"GetDeviceMountPath failed, but unmount operation will proceed using deviceMountPath=%s: %v", deviceMountPath, err), ""))
}
refs, err := deviceMountableVolumePlugin.GetDeviceMountRefs(deviceMountPath)