Do not try to set local_gb to -1 when the matched root device size is 0
Apparently, virtual floppies on some machines are represented as normal block devices, but with size = 0. We should filter them out in ironic-lib, but for now at least don't fail miserably. Story: #2007907 Task: #40308 Change-Id: Ia96a9a8b85841612fb13616754bfdbf651b212d8
This commit is contained in:
parent
a1f8926cd1
commit
95e103d21c
@ -76,6 +76,12 @@ class RootDiskSelectionHook(base.ProcessingHook):
|
||||
root_disk = introspection_data.get('root_disk')
|
||||
if root_disk:
|
||||
local_gb = root_disk['size'] // units.Gi
|
||||
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',
|
||||
|
@ -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
Normal file
5
releasenotes/notes/zero-size-55c4b4f2b9e8384d.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
No longer tries to set ``local_gb`` to -1 if the matched root device has
|
||||
size of zero.
|
Loading…
Reference in New Issue
Block a user