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)
"""
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(