From 901e084a9839ac5bb60e1c491c96f41da07eb051 Mon Sep 17 00:00:00 2001 From: Huamin Chen Date: Fri, 14 Oct 2016 13:05:14 -0400 Subject: [PATCH] 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 --- .../operationexecutor/operation_executor.go | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/pkg/volume/util/operationexecutor/operation_executor.go b/pkg/volume/util/operationexecutor/operation_executor.go index 2e15b8d39a3..6ec01a3757b 100644 --- a/pkg/volume/util/operationexecutor/operation_executor.go +++ b/pkg/volume/util/operationexecutor/operation_executor.go @@ -961,15 +961,26 @@ func (oe *operationExecutor) generateUnmountDeviceFunc( unmountDeviceErr) } // 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. - 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) + isDevicePath, devicePathErr := mounter.PathIsDevice(deviceToDetach.DevicePath) + var deviceOpened bool + var deviceOpenedErr error + if !isDevicePath && devicePathErr == nil { + // not a device path or path doesn't exist + //TODO: refer to #36092 + 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. if deviceOpened {