Skip to content

Commit

Permalink
Fix a "zfs destroy" failed on "busy" zvol just after drbd unprov
Browse files Browse the repository at this point in the history
Implement a retry loop.
  • Loading branch information
cvaroqui authored and cgalibern committed Feb 11, 2021
1 parent c9e38e3 commit ab96721
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions opensvc/drivers/resource/disk/zvol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,23 @@ def unprovisioner(self):
if not self.has_it():
self.log.info("zvol %s already destroyed", self.name)
return
cmd = [Env.syspaths.zfs, "destroy", "-f", self.name]
ret, out, err = self.vcall(cmd)
if ret != 0:
raise ex.Error
self.destroy()
self.svc.node.unset_lazy("devtree")

def destroy(self):
def fn():
ret, out, err = self._destroy()
if ret == 0:
return True
if "busy" in err:
return False
raise ex.Error(err)
self.wait_for_fn(fn, 10, 3, errmsg="waited too long for zvol destruction (busy)")

def _destroy(self):
cmd = [Env.syspaths.zfs, "destroy", "-f", self.name]
return self.vcall(cmd)

def provisioner(self):
if self.has_it():
self.log.info("zvol %s already exists", self.name)
Expand Down

0 comments on commit ab96721

Please sign in to comment.