Add 'sgdisk -Z' to destroy_disk_metadata

Apparently, wipefs still leaves some metadata around, which can break ceph.
Use sgdisk's zapping feature to be absolutely sure.

Change-Id: I51aea8fb5ba02d63a05a3794405caf000ff28e75
Closes-Bug: #1690458
This commit is contained in:
Dmitry Tantsur 2017-05-30 17:05:22 +02:00
parent 9b62156880
commit 4491a52c90
2 changed files with 22 additions and 0 deletions

View File

@ -367,6 +367,9 @@ def destroy_disk_metadata(dev, node_uuid):
run_as_root=True,
use_standard_locale=True)
utils.execute('sgdisk', '-Z', dev, run_as_root=True,
use_standard_locale=True)
LOG.info("Disk metadata on %(dev)s successfully destroyed for node "
"%(node)s", {'dev': dev, 'node': node_uuid})

View File

@ -452,6 +452,9 @@ class DestroyMetaDataTestCase(base.IronicLibTestCase):
def test_destroy_disk_metadata(self, mock_exec):
expected_calls = [mock.call('wipefs', '--force', '--all', 'fake-dev',
run_as_root=True,
use_standard_locale=True),
mock.call('sgdisk', '-Z', 'fake-dev',
run_as_root=True,
use_standard_locale=True)]
disk_utils.destroy_disk_metadata(self.dev, self.node_uuid)
@ -469,9 +472,25 @@ class DestroyMetaDataTestCase(base.IronicLibTestCase):
self.node_uuid)
mock_exec.assert_has_calls(expected_call)
def test_destroy_disk_metadata_sgdisk_fail(self, mock_exec):
expected_calls = [mock.call('wipefs', '--force', '--all', 'fake-dev',
run_as_root=True,
use_standard_locale=True),
mock.call('sgdisk', '-Z', 'fake-dev',
run_as_root=True,
use_standard_locale=True)]
mock_exec.side_effect = [(None, None),
processutils.ProcessExecutionError()]
self.assertRaises(processutils.ProcessExecutionError,
disk_utils.destroy_disk_metadata,
self.dev,
self.node_uuid)
mock_exec.assert_has_calls(expected_calls)
def test_destroy_disk_metadata_wipefs_not_support_force(self, mock_exec):
mock_exec.side_effect = iter(
[processutils.ProcessExecutionError(description='--force'),
(None, None),
(None, None)])
expected_call = [mock.call('wipefs', '--force', '--all', 'fake-dev',