From b417d0ffa0fd46611ce9d4bdfe797259f9c26c3c Mon Sep 17 00:00:00 2001 From: Arne Wiebalck Date: Fri, 17 Apr 2020 18:28:19 +0200 Subject: [PATCH] Don't break UEFI install with older IPAs For Software RAID, we need to pass the boot mode to the IPA via a new parameter. In case the IPA does not understand this new parameter yet, we catch the error and fail for UEFI. This patch proposes to only fail in the case of software RAID, since the older IPA can handle the general case of UEFIi, e.g. with a whole disk image. Change-Id: Id6b51dd19e83d20dc8d6d312cbec12d09bfd76c1 --- ironic/drivers/modules/agent_base.py | 3 ++- ironic/drivers/modules/agent_client.py | 9 +++++---- .../tests/unit/drivers/modules/test_agent_base.py | 15 ++++++++------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ironic/drivers/modules/agent_base.py b/ironic/drivers/modules/agent_base.py index be7a7dd73e..7d331d5633 100644 --- a/ironic/drivers/modules/agent_base.py +++ b/ironic/drivers/modules/agent_base.py @@ -1095,7 +1095,8 @@ class AgentDeployMixin(HeartbeatMixin): node, root_uuid=root_uuid, efi_system_part_uuid=efi_system_part_uuid, prep_boot_part_uuid=prep_boot_part_uuid, - target_boot_mode=target_boot_mode + target_boot_mode=target_boot_mode, + software_raid=software_raid ) if result['command_status'] == 'FAILED': if not whole_disk_image: diff --git a/ironic/drivers/modules/agent_client.py b/ironic/drivers/modules/agent_client.py index feb4ebc88d..eba9e6de83 100644 --- a/ironic/drivers/modules/agent_client.py +++ b/ironic/drivers/modules/agent_client.py @@ -276,7 +276,8 @@ class AgentClient(object): @METRICS.timer('AgentClient.install_bootloader') def install_bootloader(self, node, root_uuid, target_boot_mode, efi_system_part_uuid=None, - prep_boot_part_uuid=None): + prep_boot_part_uuid=None, + software_raid=False): """Install a boot loader on the image. :param node: A node object. @@ -315,12 +316,12 @@ class AgentClient(object): wait=True, command_timeout_factor=2) except exception.AgentAPIError: - # NOTE(arne_wiebalck): If we require to pass 'uefi' as the boot - # mode, but find that the IPA does not yet support the additional + # NOTE(arne_wiebalck): If for software RAID and 'uefi' as the boot + # mode, we find that the IPA does not yet support the additional # 'target_boot_mode' parameter, we need to fail. For 'bios' boot # mode on the other hand we can retry without the parameter, # since 'bios' is the default value the IPA will use. - if target_boot_mode == 'uefi': + if target_boot_mode == 'uefi' and software_raid: LOG.error('Unable to pass UEFI boot mode to an out of date ' 'agent ramdisk. Please contact the administrator ' 'to update the ramdisk to contain an ' diff --git a/ironic/tests/unit/drivers/modules/test_agent_base.py b/ironic/tests/unit/drivers/modules/test_agent_base.py index 30a0cb9ddd..02d271110a 100644 --- a/ironic/tests/unit/drivers/modules/test_agent_base.py +++ b/ironic/tests/unit/drivers/modules/test_agent_base.py @@ -1101,7 +1101,7 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest): install_bootloader_mock.assert_called_once_with( mock.ANY, task.node, root_uuid='some-root-uuid', efi_system_part_uuid=None, prep_boot_part_uuid=None, - target_boot_mode='whatever' + target_boot_mode='whatever', software_raid=False ) @mock.patch.object(agent_client.AgentClient, 'install_bootloader', @@ -1126,7 +1126,7 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest): install_bootloader_mock.assert_called_once_with( mock.ANY, task.node, root_uuid='some-root-uuid', efi_system_part_uuid=None, prep_boot_part_uuid='fake-prep', - target_boot_mode='whatever' + target_boot_mode='whatever', software_raid=False ) @mock.patch.object(agent_client.AgentClient, 'install_bootloader', @@ -1152,7 +1152,7 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest): mock.ANY, task.node, root_uuid='some-root-uuid', efi_system_part_uuid='efi-system-part-uuid', prep_boot_part_uuid=None, - target_boot_mode='uefi' + target_boot_mode='uefi', software_raid=False ) @mock.patch.object(deploy_utils, 'try_set_boot_device', autospec=True) @@ -1199,7 +1199,8 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest): install_bootloader_mock.assert_called_once_with( mock.ANY, task.node, root_uuid=None, efi_system_part_uuid='efi-system-part-uuid', - prep_boot_part_uuid=None, target_boot_mode='uefi') + prep_boot_part_uuid=None, target_boot_mode='uefi', + software_raid=False) @mock.patch.object(image_service, 'GlanceImageService', autospec=True) @mock.patch.object(deploy_utils, 'try_set_boot_device', autospec=True) @@ -1264,7 +1265,7 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest): install_bootloader_mock.assert_called_once_with( mock.ANY, task.node, root_uuid=root_uuid, efi_system_part_uuid=None, prep_boot_part_uuid=None, - target_boot_mode='bios') + target_boot_mode='bios', software_raid=True) try_set_boot_device_mock.assert_called_once_with( task, boot_devices.DISK, persistent=True) @@ -1366,7 +1367,7 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest): install_bootloader_mock.assert_called_once_with( mock.ANY, task.node, root_uuid='some-root-uuid', efi_system_part_uuid=None, prep_boot_part_uuid=None, - target_boot_mode='whatever' + target_boot_mode='whatever', software_raid=False ) collect_logs_mock.assert_called_once_with(mock.ANY, task.node) self.assertEqual(states.DEPLOYFAIL, task.node.provision_state) @@ -1399,7 +1400,7 @@ class AgentDeployMixinTest(AgentDeployMixinBaseTest): install_bootloader_mock.assert_called_once_with( mock.ANY, task.node, root_uuid='some-root-uuid', efi_system_part_uuid=None, prep_boot_part_uuid=None, - target_boot_mode='whatever') + target_boot_mode='whatever', software_raid=False) try_set_boot_device_mock.assert_called_once_with( task, boot_devices.DISK, persistent=True) collect_logs_mock.assert_called_once_with(mock.ANY, task.node)