Unverified Commit 75af0646 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #59034 from wenlxie/githubupstream.master.ignoreloopdevicenotfounderrorforrbd

Automatic merge from submit-queue (batch tested with PRs 59034, 63565, 63533). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. [RBD block device ]ignore the loopbackdevice error, or the rbd volume will not get detached The rbd volume loop device maybe not found and then the volume will not get detached. so need to ignore the error. @mtanino @sbezverk Can you take a look? Release note: ``` ignore the loopback device not found error when `GetLoopDevice` ```
parents f5f13cc5 fd20c8b0
...@@ -936,14 +936,20 @@ func (rbd *rbdDiskUnmapper) TearDownDevice(mapPath, _ string) error { ...@@ -936,14 +936,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)
// Remove loop device before detaching volume since volume detach operation gets busy if volume is opened by loopback. }
err = volumepathhandler.BlockVolumePathHandler.RemoveLoopDevice(blkUtil, loop) glog.Warning("rbd: loopback for device: % not found", device)
if err != nil { } else {
return fmt.Errorf("rbd: failed to remove loopback :%v, err: %v", loop, err) 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)
}
} }
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 {
......
...@@ -1068,11 +1068,18 @@ func (og *operationGenerator) GenerateUnmapDeviceFunc( ...@@ -1068,11 +1068,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)
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment