Browse Source

Try luksFormat up to 3 times in case the device is in use

Cinder change I03f8cae05cc117e14f7482115de685fc9f3fa54a is failing for
some volume driver third party CI like NetApp iSCSI because the device
is in use when formatting the device for LUKS.

This change adds a retry counter to the luksFormat command execution
like we did in commit eef97cdf4b for
closing the volume and hitting intermittent in-use issues.

Closes-Bug: #1470562
Related-Bug: #1440227

Change-Id: I0cb32a6f9fbe68ae033ad00534512aa5d82a417b
tags/12.0.0.0b3
Matt Riedemann 5 years ago
parent
commit
3aabe378b1
2 changed files with 3 additions and 3 deletions
  1. +2
    -2
      nova/tests/unit/volume/encryptors/test_luks.py
  2. +1
    -1
      nova/volume/encryptors/luks.py

+ 2
- 2
nova/tests/unit/volume/encryptors/test_luks.py View File

@@ -61,7 +61,7 @@ class LuksEncryptorTestCase(test_cryptsetup.CryptsetupEncryptorTestCase):
mock.call('cryptsetup', '--batch-mode', 'luksFormat',
'--key-file=-', self.dev_path,
process_input='passphrase',
run_as_root=True, check_exit_code=True),
run_as_root=True, check_exit_code=True, attempts=3),
])
self.assertEqual(1, mock_execute.call_count)

@@ -118,7 +118,7 @@ class LuksEncryptorTestCase(test_cryptsetup.CryptsetupEncryptorTestCase):
run_as_root=True, check_exit_code=True),
mock.call('cryptsetup', '--batch-mode', 'luksFormat',
'--key-file=-', self.dev_path, process_input='0' * 32,
run_as_root=True, check_exit_code=True),
run_as_root=True, check_exit_code=True, attempts=3),
mock.call('cryptsetup', 'luksOpen', '--key-file=-', self.dev_path,
self.dev_name, process_input='0' * 32,
run_as_root=True, check_exit_code=True),


+ 1
- 1
nova/volume/encryptors/luks.py View File

@@ -75,7 +75,7 @@ class LuksEncryptor(cryptsetup.CryptsetupEncryptor):
cmd.extend([self.dev_path])

utils.execute(*cmd, process_input=passphrase,
check_exit_code=True, run_as_root=True)
check_exit_code=True, run_as_root=True, attempts=3)

def _open_volume(self, passphrase, **kwargs):
"""Opens the LUKS partition on the volume using the specified


Loading…
Cancel
Save