diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 5353e976e..6808f6766 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -520,7 +520,7 @@ class ImageExtension(base.BaseAgentExtension): has_efibootmgr = True try: utils.execute('efibootmgr', '--version') - except errors.CommandExecutionError: + except FileNotFoundError: LOG.warning("efibootmgr is not available in the ramdisk") has_efibootmgr = False diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py index 44dce7b7a..a7c24b3a4 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -293,6 +293,21 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n prep_boot_part_uuid=self.fake_prep_boot_part_uuid) mock_iscsi_clean.assert_called_once_with(self.fake_dev) + @mock.patch.object(os.path, 'exists', lambda *_: False) + @mock.patch.object(iscsi, 'clean_up', autospec=True) + def test_install_bootloader_failure(self, mock_iscsi_clean, mock_execute, + mock_dispatch): + mock_dispatch.side_effect = [ + self.fake_dev, hardware.BootInfo(current_boot_mode='uefi') + ] + mock_execute.side_effect = FileNotFoundError + self.assertRaises(FileNotFoundError, + self.agent_extension.install_bootloader, + root_uuid=self.fake_root_uuid, + efi_system_part_uuid=None) + expected = [mock.call('efibootmgr', '--version')] + mock_execute.assert_has_calls(expected) + @mock.patch.object(image, '_is_bootloader_loaded', lambda *_: False) @mock.patch.object(hardware, 'is_md_device', autospec=True) @mock.patch.object(hardware, 'md_get_raid_devices', autospec=True) diff --git a/releasenotes/notes/fixes-error-handling-of-efibootmgr-not-present-in-ramdisk-f11b4241edcf0e81.yaml b/releasenotes/notes/fixes-error-handling-of-efibootmgr-not-present-in-ramdisk-f11b4241edcf0e81.yaml new file mode 100644 index 000000000..5e6f6d0c7 --- /dev/null +++ b/releasenotes/notes/fixes-error-handling-of-efibootmgr-not-present-in-ramdisk-f11b4241edcf0e81.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes error handling if efibootmgr is not present in ramdisk. + See `story `_ + for more details.