Merge "Ignore errorcode=4 when executing `cryptsetup remove` command" into stable/liberty

This commit is contained in:
Jenkins 2016-03-24 03:06:32 +00:00 committed by Gerrit Code Review
commit 3f217a441a
2 changed files with 6 additions and 3 deletions

View File

@ -78,7 +78,7 @@ class CryptsetupEncryptorTestCase(test_base.VolumeEncryptorTestCase):
mock_execute.assert_has_calls([
mock.call('cryptsetup', 'remove', self.dev_name,
run_as_root=True, check_exit_code=True),
run_as_root=True, check_exit_code=[0, 4]),
])
self.assertEqual(1, mock_execute.call_count)
@ -88,7 +88,7 @@ class CryptsetupEncryptorTestCase(test_base.VolumeEncryptorTestCase):
mock_execute.assert_has_calls([
mock.call('cryptsetup', 'remove', self.dev_name,
run_as_root=True, check_exit_code=True),
run_as_root=True, check_exit_code=[0, 4]),
])
self.assertEqual(1, mock_execute.call_count)

View File

@ -103,8 +103,11 @@ class CryptsetupEncryptor(base.VolumeEncryptor):
def _close_volume(self, **kwargs):
"""Closes the device (effectively removes the dm-crypt mapping)."""
LOG.debug("closing encrypted volume %s", self.dev_path)
# cryptsetup returns 4 when attempting to destroy a non-active
# dm-crypt device. We are going to ignore this error code to make
# nova deleting that instance successfully.
utils.execute('cryptsetup', 'remove', self.dev_name,
run_as_root=True, check_exit_code=True)
run_as_root=True, check_exit_code=[0, 4])
def detach_volume(self, **kwargs):
"""Removes the dm-crypt mapping for the device."""