Browse Source

Merge "Do not try to set local_gb to -1 when the matched root device size is 0"

changes/06/742306/1
Zuul 2 years ago committed by Gerrit Code Review
parent
commit
5a9e5e101d
  1. 16
      ironic_inspector/plugins/standard.py
  2. 10
      ironic_inspector/test/unit/test_plugins_standard.py
  3. 5
      releasenotes/notes/zero-size-55c4b4f2b9e8384d.yaml

16
ironic_inspector/plugins/standard.py

@ -76,11 +76,17 @@ class RootDiskSelectionHook(base.ProcessingHook):
root_disk = introspection_data.get('root_disk')
if root_disk:
local_gb = root_disk['size'] // units.Gi
if CONF.processing.disk_partitioning_spacing:
local_gb -= 1
LOG.info('Root disk %(disk)s, local_gb %(local_gb)s GiB',
{'disk': root_disk, 'local_gb': local_gb},
node_info=node_info, data=introspection_data)
if not local_gb:
LOG.warning('The requested root disk is too small (smaller '
'than 1 GiB) or its size cannot be detected: %s',
root_disk,
node_info=node_info, data=introspection_data)
else:
if CONF.processing.disk_partitioning_spacing:
local_gb -= 1
LOG.info('Root disk %(disk)s, local_gb %(local_gb)s GiB',
{'disk': root_disk, 'local_gb': local_gb},
node_info=node_info, data=introspection_data)
else:
local_gb = 0
LOG.info('No root device found, assuming a diskless node',

10
ironic_inspector/test/unit/test_plugins_standard.py

@ -363,6 +363,7 @@ class TestRootDiskSelection(test_base.NodeTest):
{'model': 'Model 3', 'size': 10 * units.Gi, 'name': '/dev/sdc'},
{'model': 'Model 4', 'size': 4 * units.Gi, 'name': '/dev/sdd'},
{'model': 'Too Small', 'size': 1 * units.Gi, 'name': '/dev/sde'},
{'model': 'Floppy', 'size': 0, 'name': '/dev/sdf'},
]
self.matched = self.inventory['disks'][2].copy()
self.node_info = mock.Mock(spec=node_cache.NodeInfo,
@ -434,6 +435,15 @@ class TestRootDiskSelection(test_base.NodeTest):
self.assertEqual(10, self.data['local_gb'])
self.node_info.update_properties.assert_called_once_with(local_gb='10')
def test_zero_size(self):
self.node.properties['root_device'] = {'name': '/dev/sdf'}
self.hook.before_update(self.data, self.node_info)
self.assertEqual(self.inventory['disks'][5], self.data['root_disk'])
self.assertEqual(0, self.data['local_gb'])
self.node_info.update_properties.assert_called_once_with(local_gb='0')
def test_all_match(self):
self.node.properties['root_device'] = {'size': 10,
'model': 'Model 3'}

5
releasenotes/notes/zero-size-55c4b4f2b9e8384d.yaml

@ -0,0 +1,5 @@
---
fixes:
- |
No longer tries to set ``local_gb`` to -1 if the matched root device has
size of zero.
Loading…
Cancel
Save