As reported in issue 1037, LXC users could encounter a situation where
a loopback device was busy at the time Ganeti attempted to destroy it.
To prevent this from happening, an invocation of udevadm settle was
added to the blockdev preparation helper function.

Signed-off-by: Hrvoje Ribicic <[email protected]>
---
 lib/utils/storage.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/utils/storage.py b/lib/utils/storage.py
index 1efb247..c8aa2b9 100644
--- a/lib/utils/storage.py
+++ b/lib/utils/storage.py
@@ -279,6 +279,13 @@ def ReleaseBdevPartitionMapping(loop_dev_path):
     raise errors.CommandError("Failed to release partition mapping of %s: %s" %
                               (loop_dev_path, result.output))
 
+  # The invocation of udevadm settle was added here because users had issues
+  # with the loopback device still being busy after kpartx / earlier commands
+  # did their work.
+  result = utils_process.RunCmd(["udevadm", "settle"])
+  if result.failed:
+    raise errors.CommandError("Waiting on udev failed: %s" % result.output)
+
   result = utils_process.RunCmd(["losetup", "-d", loop_dev_path])
   if result.failed:
     raise errors.CommandError("Failed to detach %s: %s" %
-- 
2.2.0.rc0.207.ga3a616c

Reply via email to