Fix get_boot_option logic for software raid

get_boot_option returns what the effective boot
option is for the scenario at hand for deployment.

That being said, it was never updated to account for the
presence of software raid. It will now return "local" as
the boot option when software raid is configured, as
Software RAID is only supported in local boot mode.

Change-Id: I2441cd60bb385648570e5994194e6fc6ff22025a
This commit is contained in:
Julia Kreger 2019-08-28 15:47:54 -04:00
parent 968f7876f2
commit 721aab48da
3 changed files with 52 additions and 0 deletions

View File

@ -867,10 +867,31 @@ def get_boot_option(node):
:returns: A string representing the boot option type. Defaults to :returns: A string representing the boot option type. Defaults to
'netboot'. 'netboot'.
""" """
# NOTE(TheJulia): Software raid always implies local deployment
if is_software_raid(node):
return 'local'
capabilities = utils.parse_instance_info_capabilities(node) capabilities = utils.parse_instance_info_capabilities(node)
return capabilities.get('boot_option', get_default_boot_option()).lower() return capabilities.get('boot_option', get_default_boot_option()).lower()
def is_software_raid(node):
"""Determine if software raid is in use for the deployment.
:param node: A single Node.
:returns: A boolean value of True when software raid is in use,
otherwise False
"""
target_raid_config = node.target_raid_config
logical_disks = target_raid_config.get('logical_disks', [])
software_raid = False
for logical_disk in logical_disks:
if logical_disk.get('controller') == 'software':
software_raid = True
break
return software_raid
def build_agent_options(node): def build_agent_options(node):
"""Build the options to be passed to the agent ramdisk. """Build the options to be passed to the agent ramdisk.

View File

@ -1255,6 +1255,31 @@ class OtherFunctionTestCase(db_base.DbTestCase):
result = utils.get_boot_option(self.node) result = utils.get_boot_option(self.node)
self.assertEqual("netboot", result) self.assertEqual("netboot", result)
@mock.patch.object(utils, 'is_software_raid', autospec=True)
def test_get_boot_option_software_raid(self, mock_is_software_raid):
mock_is_software_raid.return_value = True
cfg.CONF.set_override('default_boot_option', 'netboot', 'deploy')
result = utils.get_boot_option(self.node)
self.assertEqual("local", result)
def test_is_software_raid(self):
self.node.target_raid_config = {
"logical_disks": [
{
"size_gb": 100,
"raid_level": "1",
"controller": "software",
}
]
}
result = utils.is_software_raid(self.node)
self.assertTrue(result)
def test_is_software_raid_false(self):
self.node.target_raid_config = {}
result = utils.is_software_raid(self.node)
self.assertFalse(result)
@mock.patch.object(image_cache, 'clean_up_caches', autospec=True) @mock.patch.object(image_cache, 'clean_up_caches', autospec=True)
def test_fetch_images(self, mock_clean_up_caches): def test_fetch_images(self, mock_clean_up_caches):

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes a minor issue with ``get_boot_option`` logic that did not account
for Software RAID. This can erroniously cause the deployment to take the
the incorrect deployment path and attempt to install a boot loader.