Ensure that newly initialized disks are zero'd

When creating a new encrypted disk, ensure that
we zero the first region to ensure that pvcreate
won't stumble on random artifacts

Closes-Bug: #1783427
Change-Id: Iac45e9c00d093befb893c61a3c3aee70ac4b851a
This commit is contained in:
Chris MacNaughton 2018-12-11 15:59:23 +01:00
parent fec2c3188a
commit 31ffa13124
2 changed files with 15 additions and 5 deletions

View File

@ -1814,6 +1814,13 @@ def _initialize_disk(dev, dev_uuid, encrypt=False,
'--uuid', dev_uuid,
dev,
])
subprocess.check_call([
'dd',
'if=/dev/zero',
'of={}'.format(dm_crypt),
'bs=512',
'count=1',
])
if use_vaultlocker:
return dm_crypt

View File

@ -851,11 +851,14 @@ class CephInitializeDiskTestCase(unittest.TestCase):
True,
'vault'),
'/dev/mapper/crypt-test-UUID')
_check_call.assert_called_once_with(
['vaultlocker', 'encrypt',
'--uuid', 'test-UUID',
'/dev/sdb']
)
_check_call.assert_has_calls([
call(['vaultlocker', 'encrypt',
'--uuid', 'test-UUID',
'/dev/sdb']),
call(['dd', 'if=/dev/zero',
'of=/dev/mapper/crypt-test-UUID',
'bs=512', 'count=1']),
])
@patch.object(utils, '_luks_uuid')
@patch.object(utils.subprocess, 'check_call')