diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 9af65d7e3..739d61861 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -168,6 +168,14 @@ def _is_bootloader_loaded(dev): return True return False + boot = hardware.dispatch_to_managers('get_boot_info') + + if boot.current_boot_mode != 'bios': + # We're in UEFI mode, this logic is invalid + LOG.debug('Skipping boot sector check as the system is in UEFI ' + 'boot mode.') + return False + try: # Looking for things marked "bootable" in the partition table stdout, stderr = utils.execute('parted', dev, '-s', '-m', diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py index 616476fe9..e90249078 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -704,6 +704,8 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n def test__is_bootloader_loaded(self, mock_execute, mock_dispatch): + mock_dispatch.return_value = hardware.BootInfo( + current_boot_mode='bios') parted_output = ('BYT;\n' '/dev/loop1:46.1MB:loopback:512:512:gpt:Loopback ' 'device:;\n' @@ -758,6 +760,16 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n result = image._is_bootloader_loaded(self.fake_dev) self.assertFalse(result) + def test__is_bootloader_loaded_uefi_mode(self, mock_execute, + mock_dispatch): + + mock_dispatch.return_value = hardware.BootInfo( + current_boot_mode='uefi') + result = image._is_bootloader_loaded(self.fake_dev) + self.assertFalse(result) + mock_dispatch.assert_any_call('get_boot_info') + self.assertEqual(0, mock_execute.call_count) + @mock.patch.object(image, '_get_partition', autospec=True) @mock.patch.object(utils, 'get_efi_part_on_device', autospec=True) def test__manage_uefi_no_partition(self, mock_utils_efi_part, diff --git a/releasenotes/notes/bootloader-ignored-uefi-mode-8578a009d5b5be62.yaml b/releasenotes/notes/bootloader-ignored-uefi-mode-8578a009d5b5be62.yaml new file mode 100644 index 000000000..e570f3533 --- /dev/null +++ b/releasenotes/notes/bootloader-ignored-uefi-mode-8578a009d5b5be62.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes an issue with deployment ramdisks running in UEFI boot mode where + dual-boot images may cause the logic to prematurely exit before UEFI + parameters can be updated. Internal checks for a BIOS bootloader will + always return ``False`` now when the machine is in UEFI mode.