diff --git a/pkg/volume/util/operationexecutor/operation_generator.go b/pkg/volume/util/operationexecutor/operation_generator.go index 9f86cf93f8e..5a98946c6f3 100644 --- a/pkg/volume/util/operationexecutor/operation_generator.go +++ b/pkg/volume/util/operationexecutor/operation_generator.go @@ -20,6 +20,7 @@ import ( "context" goerrors "errors" "fmt" + "os" "path/filepath" "strings" "time" @@ -1202,7 +1203,12 @@ func (og *operationGenerator) GenerateUnmapDeviceFunc( globalMapPath := deviceToDetach.DeviceMountPath refs, err := og.blkUtil.GetDeviceBindMountRefs(deviceToDetach.DevicePath, globalMapPath) if err != nil { - return deviceToDetach.GenerateError("UnmapDevice.GetDeviceBindMountRefs check failed", err) + if os.IsNotExist(err) { + // Looks like SetupDevice did not complete. Fall through to TearDownDevice and mark the device as unmounted. + refs = nil + } else { + return deviceToDetach.GenerateError("UnmapDevice.GetDeviceBindMountRefs check failed", err) + } } if len(refs) > 0 { err = fmt.Errorf("The device %q is still referenced from other Pods %v", globalMapPath, refs) diff --git a/pkg/volume/util/volumepathhandler/volume_path_handler.go b/pkg/volume/util/volumepathhandler/volume_path_handler.go index 9c0983bbf73..6f198302dc0 100644 --- a/pkg/volume/util/volumepathhandler/volume_path_handler.go +++ b/pkg/volume/util/volumepathhandler/volume_path_handler.go @@ -283,7 +283,7 @@ func (v VolumePathHandler) GetDeviceBindMountRefs(devPath string, mapPath string var refs []string files, err := ioutil.ReadDir(mapPath) if err != nil { - return nil, fmt.Errorf("directory cannot read %v", err) + return nil, err } for _, file := range files { if file.Mode()&os.ModeDevice != os.ModeDevice {