mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 13:42:02 +00:00
checking if the device path is valid before calling DeviceOpened() to avoid false negative on devices that don't exist any more
Signed-off-by: Huamin Chen <hchen@redhat.com>
This commit is contained in:
@@ -961,15 +961,26 @@ func (oe *operationExecutor) generateUnmountDeviceFunc(
|
|||||||
unmountDeviceErr)
|
unmountDeviceErr)
|
||||||
}
|
}
|
||||||
// Before logging that UnmountDevice succeeded and moving on,
|
// Before logging that UnmountDevice succeeded and moving on,
|
||||||
// use mounter.DeviceOpened to check if the device is in use anywhere
|
// use mounter.PathIsDevice to check if the path is a device,
|
||||||
|
// if so use mounter.DeviceOpened to check if the device is in use anywhere
|
||||||
// else on the system. Retry if it returns true.
|
// else on the system. Retry if it returns true.
|
||||||
deviceOpened, deviceOpenedErr := mounter.DeviceOpened(deviceToDetach.DevicePath)
|
isDevicePath, devicePathErr := mounter.PathIsDevice(deviceToDetach.DevicePath)
|
||||||
if deviceOpenedErr != nil {
|
var deviceOpened bool
|
||||||
return fmt.Errorf(
|
var deviceOpenedErr error
|
||||||
"UnmountDevice.DeviceOpened failed for volume %q (spec.Name: %q) with: %v",
|
if !isDevicePath && devicePathErr == nil {
|
||||||
deviceToDetach.VolumeName,
|
// not a device path or path doesn't exist
|
||||||
deviceToDetach.VolumeSpec.Name(),
|
//TODO: refer to #36092
|
||||||
deviceOpenedErr)
|
glog.V(3).Infof("Not checking device path %s", deviceToDetach.DevicePath)
|
||||||
|
deviceOpened = false
|
||||||
|
} else {
|
||||||
|
deviceOpened, deviceOpenedErr = mounter.DeviceOpened(deviceToDetach.DevicePath)
|
||||||
|
if deviceOpenedErr != nil {
|
||||||
|
return fmt.Errorf(
|
||||||
|
"UnmountDevice.DeviceOpened failed for volume %q (spec.Name: %q) with: %v",
|
||||||
|
deviceToDetach.VolumeName,
|
||||||
|
deviceToDetach.VolumeSpec.Name(),
|
||||||
|
deviceOpenedErr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// The device is still in use elsewhere. Caller will log and retry.
|
// The device is still in use elsewhere. Caller will log and retry.
|
||||||
if deviceOpened {
|
if deviceOpened {
|
||||||
|
Reference in New Issue
Block a user