Fix to reflect commnet

- Change not to skip error from GetLoopDevice other than DeviceNotFound
- Add comment for the reason for order of descriptor lock release and TearDownDevice
pull/58/head
Masaki Kimura 2018-10-03 22:31:51 +00:00
parent 3d808540df
commit 4226ae7a61
1 changed files with 5 additions and 4 deletions

View File

@ -1080,15 +1080,16 @@ func (og *operationGenerator) GenerateUnmapDeviceFunc(
}
// The block volume is not referenced from Pods. Release file descriptor lock.
// This should be done before calling TearDownDevice, because some plugins that do local detach
// in TearDownDevice will fail in detaching device due to the refcnt on the loopback device.
glog.V(4).Infof("UnmapDevice: deviceToDetach.DevicePath: %v", deviceToDetach.DevicePath)
loopPath, err := og.blkUtil.GetLoopDevice(deviceToDetach.DevicePath)
if err != nil {
if err.Error() == volumepathhandler.ErrDeviceNotFound {
glog.Warningf(deviceToDetach.GenerateMsgDetailed("UnmapDevice: Couldn't find loopback device which takes file descriptor lock",
fmt.Sprintf("device path: %q", deviceToDetach.DevicePath)))
glog.Warningf(deviceToDetach.GenerateMsgDetailed("UnmapDevice: Couldn't find loopback device which takes file descriptor lock", fmt.Sprintf("device path: %q", deviceToDetach.DevicePath)))
} else {
glog.Warningf(deviceToDetach.GenerateMsgDetailed("UnmapDevice: GetLoopDevice failed to get loopback device",
fmt.Sprintf("device path: %q", deviceToDetach.DevicePath)))
errInfo := "UnmapDevice.GetLoopDevice failed to get loopback device, " + fmt.Sprintf("device path: %q", deviceToDetach.DevicePath)
return deviceToDetach.GenerateError(errInfo, err)
}
} else {
if len(loopPath) != 0 {