From 4da2f9494dbd72e84d381cc12125c61931a27628 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Wed, 6 Jan 2016 11:15:19 +0100 Subject: [PATCH] ceph-disk: retry cryptsetup remove 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 (cherry picked from commit 132e56615805cba0395898cf165b32b88600d633) --- src/ceph-disk | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ceph-disk b/src/ceph-disk index cfcb817182638..a26c1083957e2 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -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( -- 2.39.5