summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-02-04 02:52:48 +0000
committerGerrit Code Review <review@openstack.org>2020-02-04 02:52:48 +0000
commit53940f65f4b383fad77fb1b2f22b0e978803895a (patch)
treefbb1405617fb484c0bb8d0c696d8dd6ca3dd24f3
parent1e7447a1764a1ca0de2005097570a8dc6d1125e3 (diff)
parent721aab48da451a65c957ca2289328363b647c6df (diff)
downloadironic-53940f65f4b383fad77fb1b2f22b0e978803895a.tar.gz
Merge "Fix get_boot_option logic for software raid"
-rw-r--r--ironic/drivers/modules/deploy_utils.py21
-rw-r--r--ironic/tests/unit/drivers/modules/test_deploy_utils.py25
-rw-r--r--releasenotes/notes/fixes-get-boot-option-for-software-raid-baa2cffd95e1f624.yaml6
3 files changed, 52 insertions, 0 deletions
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py
index 3b5c733c7..9e26e0c4b 100644
--- a/ironic/drivers/modules/deploy_utils.py
+++ b/ironic/drivers/modules/deploy_utils.py
@@ -857,10 +857,31 @@ def get_boot_option(node):
:returns: A string representing the boot option type. Defaults to
'netboot'.
"""
+
+ # NOTE(TheJulia): Software raid always implies local deployment
+ if is_software_raid(node):
+ return 'local'
capabilities = utils.parse_instance_info_capabilities(node)
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):
"""Build the options to be passed to the agent ramdisk.
diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py
index 7f448df30..9624286b5 100644
--- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py
+++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py
@@ -1255,6 +1255,31 @@ class OtherFunctionTestCase(db_base.DbTestCase):
result = utils.get_boot_option(self.node)
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)
def test_fetch_images(self, mock_clean_up_caches):
diff --git a/releasenotes/notes/fixes-get-boot-option-for-software-raid-baa2cffd95e1f624.yaml b/releasenotes/notes/fixes-get-boot-option-for-software-raid-baa2cffd95e1f624.yaml
new file mode 100644
index 000000000..849273ac8
--- /dev/null
+++ b/releasenotes/notes/fixes-get-boot-option-for-software-raid-baa2cffd95e1f624.yaml
@@ -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.