]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: retry cryptsetup remove
authorLoic Dachary <ldachary@redhat.com>
Wed, 6 Jan 2016 10:15:19 +0000 (11:15 +0100)
committerLoic Dachary <ldachary@redhat.com>
Wed, 6 Jan 2016 15:59:58 +0000 (16:59 +0100)
Retry a cryptsetup remove ten times. After the ceph-osd terminates, the
device is released asyncrhonously and an attempt to cryptsetup remove
will may fail because it is considered busy. Although a few attempts are
made before giving up, the number of attempts / the duration of the
attempts cannot be controlled with a cryptsetup option. The workaround
is to increase this by trying a few times.

If cryptsetup remove fails for a reason that is unrelated to timeout,
the error will be repeated a few times. There is no undesirable side
effect. It will not hide a problem.

Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 132e56615805cba0395898cf165b32b88600d633)

src/ceph-disk

index cfcb817182638f73dd0a933eb251b9aba96b7e70..a26c1083957e2523d9a8d669b4115e16f1f79dd3 100755 (executable)
@@ -1066,17 +1066,17 @@ def dmcrypt_unmap(
     """
     Removes the dmcrypt device with the given UUID.
     """
-    args = [
-        'cryptsetup',
-        'remove',
-        _uuid
-    ]
-
-    try:
-        command_check_call(args)
-
-    except subprocess.CalledProcessError as e:
-        raise Error('unable to unmap device', _uuid, e)
+    retries = 0
+    while True:
+        try:
+            command_check_call(['cryptsetup', 'remove', _uuid])
+            break
+        except subprocess.CalledProcessError as e:
+            if retries == 10:
+                raise Error('unable to unmap device', _uuid, e)
+            else:
+                time.sleep(0.5 + retries * 1.0)
+                retries += 1
 
 
 def mount(