Merge "Software RAID: Ignore missing component devices or holder disks"
This commit is contained in:
commit
187d5da057
ironic_python_agent
@ -127,15 +127,16 @@ def _get_component_devices(raid_device):
|
|||||||
if not raid_device:
|
if not raid_device:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
component_devices = []
|
|
||||||
try:
|
try:
|
||||||
out, _ = utils.execute('mdadm', '--detail', raid_device,
|
out, _ = utils.execute('mdadm', '--detail', raid_device,
|
||||||
use_standard_locale=True)
|
use_standard_locale=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
msg = ('Could not get component devices of %(dev)s: %(err)s' %
|
msg = ('Could not get component devices of %(dev)s: %(err)s' %
|
||||||
{'dev': raid_device, 'err': e})
|
{'dev': raid_device, 'err': e})
|
||||||
raise errors.SoftwareRAIDError(msg)
|
LOG.warning(msg)
|
||||||
|
return []
|
||||||
|
|
||||||
|
component_devices = []
|
||||||
lines = out.splitlines()
|
lines = out.splitlines()
|
||||||
# the first line contains the md device itself
|
# the first line contains the md device itself
|
||||||
for line in lines[1:]:
|
for line in lines[1:]:
|
||||||
@ -156,16 +157,16 @@ def get_holder_disks(raid_device):
|
|||||||
if not raid_device:
|
if not raid_device:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
holder_disks = []
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
out, _ = utils.execute('mdadm', '--detail', raid_device,
|
out, _ = utils.execute('mdadm', '--detail', raid_device,
|
||||||
use_standard_locale=True)
|
use_standard_locale=True)
|
||||||
except processutils.ProcessExecutionError as e:
|
except processutils.ProcessExecutionError as e:
|
||||||
msg = ('Could not get holder disks of %(dev)s: %(err)s' %
|
msg = ('Could not get holder disks of %(dev)s: %(err)s' %
|
||||||
{'dev': raid_device, 'err': e})
|
{'dev': raid_device, 'err': e})
|
||||||
raise errors.SoftwareRAIDError(msg)
|
LOG.warning(msg)
|
||||||
|
return []
|
||||||
|
|
||||||
|
holder_disks = []
|
||||||
lines = out.splitlines()
|
lines = out.splitlines()
|
||||||
# the first line contains the md device itself
|
# the first line contains the md device itself
|
||||||
|
|
||||||
@ -1569,12 +1570,21 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
raid_devices = list_all_block_devices(block_type='raid',
|
raid_devices = list_all_block_devices(block_type='raid',
|
||||||
ignore_raid=False)
|
ignore_raid=False)
|
||||||
for raid_device in raid_devices:
|
for raid_device in raid_devices:
|
||||||
|
component_devices = _get_component_devices(raid_device.name)
|
||||||
|
if not component_devices:
|
||||||
|
# A "Software RAID device" without components is usually
|
||||||
|
# a partition on an md device (as, for instance, created
|
||||||
|
# by the conductor for the config drive). This will be
|
||||||
|
# cleaned with the hosting md device.
|
||||||
|
msg = ("Software RAID cleaning is skipping "
|
||||||
|
"partition %s" % raid_device.name)
|
||||||
|
LOG.info(msg)
|
||||||
|
continue
|
||||||
|
holder_disks = get_holder_disks(raid_device.name)
|
||||||
|
|
||||||
LOG.info("Deleting Software RAID device {}".format(
|
LOG.info("Deleting Software RAID device {}".format(
|
||||||
raid_device.name))
|
raid_device.name))
|
||||||
|
|
||||||
component_devices = _get_component_devices(raid_device.name)
|
|
||||||
LOG.debug('Found component devices %s', component_devices)
|
LOG.debug('Found component devices %s', component_devices)
|
||||||
holder_disks = get_holder_disks(raid_device.name)
|
|
||||||
LOG.debug('Found holder disks %s', holder_disks)
|
LOG.debug('Found holder disks %s', holder_disks)
|
||||||
|
|
||||||
# Remove md devices.
|
# Remove md devices.
|
||||||
|
@ -3128,6 +3128,19 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
|||||||
mock.call('wipefs', '-af', '/dev/sda'),
|
mock.call('wipefs', '-af', '/dev/sda'),
|
||||||
mock.call('wipefs', '-af', '/dev/sdb')])
|
mock.call('wipefs', '-af', '/dev/sdb')])
|
||||||
|
|
||||||
|
@mock.patch.object(hardware, '_get_component_devices', autospec=True)
|
||||||
|
@mock.patch.object(hardware, 'list_all_block_devices', autospec=True)
|
||||||
|
@mock.patch.object(utils, 'execute', autospec=True)
|
||||||
|
def test_delete_configuration_partition(self, mocked_execute, mocked_list,
|
||||||
|
mocked_get_component):
|
||||||
|
raid_device1_part1 = hardware.BlockDevice('/dev/md0p1', 'RAID-1',
|
||||||
|
1073741824, True)
|
||||||
|
hardware.list_all_block_devices.return_value = [raid_device1_part1]
|
||||||
|
mocked_get_component.return_value = []
|
||||||
|
|
||||||
|
self.assertIsNone(self.hardware.delete_configuration(self.node, []))
|
||||||
|
mocked_execute.assert_has_calls([])
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute', autospec=True)
|
@mock.patch.object(utils, 'execute', autospec=True)
|
||||||
def test_validate_configuration_valid_raid1(self, mocked_execute):
|
def test_validate_configuration_valid_raid1(self, mocked_execute):
|
||||||
raid_config = {
|
raid_config = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user