ignore the loopbackdevice error, or the rbd volume will not get detached
This commit is contained in:
@@ -940,14 +940,20 @@ func (rbd *rbdDiskUnmapper) TearDownDevice(mapPath, _ string) error {
|
|||||||
blkUtil := volumepathhandler.NewBlockVolumePathHandler()
|
blkUtil := volumepathhandler.NewBlockVolumePathHandler()
|
||||||
loop, err := volumepathhandler.BlockVolumePathHandler.GetLoopDevice(blkUtil, device)
|
loop, err := volumepathhandler.BlockVolumePathHandler.GetLoopDevice(blkUtil, device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("rbd: failed to get loopback for device: %v, err: %v", device, err)
|
if err.Error() != volumepathhandler.ErrDeviceNotFound {
|
||||||
|
return fmt.Errorf("rbd: failed to get loopback for device: %v, err: %v", device, err)
|
||||||
|
}
|
||||||
|
glog.Warning("rbd: loopback for device: % not found", device)
|
||||||
|
} else {
|
||||||
|
if len(loop) != 0 {
|
||||||
|
// Remove loop device before detaching volume since volume detach operation gets busy if volume is opened by loopback.
|
||||||
|
err = volumepathhandler.BlockVolumePathHandler.RemoveLoopDevice(blkUtil, loop)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("rbd: failed to remove loopback :%v, err: %v", loop, err)
|
||||||
|
}
|
||||||
|
glog.V(4).Infof("rbd: successfully removed loop device: %s", loop)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Remove loop device before detaching volume since volume detach operation gets busy if volume is opened by loopback.
|
|
||||||
err = volumepathhandler.BlockVolumePathHandler.RemoveLoopDevice(blkUtil, loop)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("rbd: failed to remove loopback :%v, err: %v", loop, err)
|
|
||||||
}
|
|
||||||
glog.V(4).Infof("rbd: successfully removed loop device: %s", loop)
|
|
||||||
|
|
||||||
err = rbd.manager.DetachBlockDisk(*rbd, mapPath)
|
err = rbd.manager.DetachBlockDisk(*rbd, mapPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -1058,11 +1058,18 @@ func (og *operationGenerator) GenerateUnmapDeviceFunc(
|
|||||||
glog.V(4).Infof("UnmapDevice: deviceToDetach.DevicePath: %v", deviceToDetach.DevicePath)
|
glog.V(4).Infof("UnmapDevice: deviceToDetach.DevicePath: %v", deviceToDetach.DevicePath)
|
||||||
loopPath, err := og.blkUtil.GetLoopDevice(deviceToDetach.DevicePath)
|
loopPath, err := og.blkUtil.GetLoopDevice(deviceToDetach.DevicePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf(deviceToDetach.GenerateMsgDetailed("UnmapDevice: Couldn't find loopback device which takes file descriptor lock", fmt.Sprintf("device path: %q", deviceToDetach.DevicePath)))
|
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)))
|
||||||
|
} else {
|
||||||
|
errInfo := "UnmapDevice.GetLoopDevice failed to get loopback device, " + fmt.Sprintf("device path: %q", deviceToDetach.DevicePath)
|
||||||
|
return deviceToDetach.GenerateError(errInfo, err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
err = og.blkUtil.RemoveLoopDevice(loopPath)
|
if len(loopPath) != 0 {
|
||||||
if err != nil {
|
err = og.blkUtil.RemoveLoopDevice(loopPath)
|
||||||
return deviceToDetach.GenerateError("UnmapDevice.AttachFileDevice failed", err)
|
if err != nil {
|
||||||
|
return deviceToDetach.GenerateError("UnmapDevice.RemoveLoopDevice failed", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user