Introduce skip list to inspector
Follow the same process of root device selection as in IPA which changed in https://review.opendev.org/c/openstack/ironic-python-agent/+/850861 The change introduces 'skip_block_devices' field into properties which contains a list of hints pointing to devices that cannot be root devices Change-Id: I94c8607ef9c610eadf1b5bce4fb154e97939a643
This commit is contained in:
parent
493cee3531
commit
5ab429d528
@ -37,6 +37,21 @@ class RootDiskSelectionHook(base.ProcessingHook):
|
|||||||
might not be updated.
|
might not be updated.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def _get_skip_list_from_node(self, node, block_devices):
|
||||||
|
skip_list_hints = node.node().properties.get("skip_block_devices", [])
|
||||||
|
if not skip_list_hints:
|
||||||
|
return
|
||||||
|
skip_list = set()
|
||||||
|
for hint in skip_list_hints:
|
||||||
|
found_devs = il_utils.find_devices_by_hints(block_devices, hint)
|
||||||
|
excluded_devs = {dev['name'] for dev in found_devs}
|
||||||
|
skipped_devices = excluded_devs.difference(skip_list)
|
||||||
|
skip_list = skip_list.union(excluded_devs)
|
||||||
|
if skipped_devices:
|
||||||
|
LOG.warning("Using hint %(hint)s skipping devices: %(devs)s",
|
||||||
|
{'hint': hint, 'devs': ','.join(skipped_devices)})
|
||||||
|
return skip_list
|
||||||
|
|
||||||
def _process_root_device_hints(self, introspection_data, node_info,
|
def _process_root_device_hints(self, introspection_data, node_info,
|
||||||
inventory):
|
inventory):
|
||||||
"""Detect root disk from root device hints and IPA inventory."""
|
"""Detect root disk from root device hints and IPA inventory."""
|
||||||
@ -46,6 +61,11 @@ class RootDiskSelectionHook(base.ProcessingHook):
|
|||||||
node_info=node_info, data=introspection_data)
|
node_info=node_info, data=introspection_data)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
skip_list = self._get_skip_list_from_node(node_info,
|
||||||
|
inventory['disks'])
|
||||||
|
if skip_list:
|
||||||
|
inventory['disks'] = [d for d in inventory['disks']
|
||||||
|
if d['name'] not in skip_list]
|
||||||
try:
|
try:
|
||||||
device = il_utils.match_root_device_hints(inventory['disks'],
|
device = il_utils.match_root_device_hints(inventory['disks'],
|
||||||
hints)
|
hints)
|
||||||
|
@ -364,6 +364,7 @@ class TestRootDiskSelection(test_base.NodeTest):
|
|||||||
{'model': 'Model 4', 'size': 4 * units.Gi, 'name': '/dev/sdd'},
|
{'model': 'Model 4', 'size': 4 * units.Gi, 'name': '/dev/sdd'},
|
||||||
{'model': 'Too Small', 'size': 1 * units.Gi, 'name': '/dev/sde'},
|
{'model': 'Too Small', 'size': 1 * units.Gi, 'name': '/dev/sde'},
|
||||||
{'model': 'Floppy', 'size': 0, 'name': '/dev/sdf'},
|
{'model': 'Floppy', 'size': 0, 'name': '/dev/sdf'},
|
||||||
|
{'model': 'Model 3', 'size': 20 * units.Gi, 'name': '/dev/sdg'},
|
||||||
]
|
]
|
||||||
self.matched = self.inventory['disks'][2].copy()
|
self.matched = self.inventory['disks'][2].copy()
|
||||||
self.node_info = mock.Mock(spec=node_cache.NodeInfo,
|
self.node_info = mock.Mock(spec=node_cache.NodeInfo,
|
||||||
@ -416,6 +417,29 @@ class TestRootDiskSelection(test_base.NodeTest):
|
|||||||
self.assertNotIn('local_gb', self.data)
|
self.assertNotIn('local_gb', self.data)
|
||||||
self.assertFalse(self.node_info.update_properties.called)
|
self.assertFalse(self.node_info.update_properties.called)
|
||||||
|
|
||||||
|
def test_one_that_matches_on_skip_list(self):
|
||||||
|
self.node.properties['root_device'] = {'size': 10}
|
||||||
|
self.node.properties['skip_block_devices'] = [{'size': 10}]
|
||||||
|
|
||||||
|
self.assertRaisesRegex(utils.Error,
|
||||||
|
'No disks satisfied root device hints',
|
||||||
|
self.hook.before_update,
|
||||||
|
self.data, self.node_info)
|
||||||
|
|
||||||
|
self.assertNotIn('local_gb', self.data)
|
||||||
|
self.assertFalse(self.node_info.update_properties.called)
|
||||||
|
|
||||||
|
def test_first_match_on_skip_list_use_second(self):
|
||||||
|
self.node.properties['root_device'] = {'model': 'Model 3'}
|
||||||
|
self.node.properties['skip_block_devices'] = [{'size': 10}]
|
||||||
|
|
||||||
|
second = self.inventory['disks'][6].copy()
|
||||||
|
self.hook.before_update(self.data, self.node_info)
|
||||||
|
|
||||||
|
self.assertEqual(second, self.data['root_disk'])
|
||||||
|
self.assertEqual(19, self.data['local_gb'])
|
||||||
|
self.node_info.update_properties.assert_called_once_with(local_gb='19')
|
||||||
|
|
||||||
def test_one_matches(self):
|
def test_one_matches(self):
|
||||||
self.node.properties['root_device'] = {'size': 10}
|
self.node.properties['root_device'] = {'size': 10}
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Follow the same process for determining root device as Ironic Python Agent
|
||||||
|
which has been changed to accommodate for the feature enabling users to
|
||||||
|
specify a list of devices that should be skipped during cleaning/deployment
|
||||||
|
The field ``skip_block_devices`` is one of the properties of a node
|
Loading…
Reference in New Issue
Block a user