From a057be7dadc898ec813b2cac14913cd8523fbbcc Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Thu, 3 Jun 2021 13:16:55 +1200 Subject: Ignore efi grub2-install failure Recent releases of redhat grub2 will always fail when installing to EFI paths, to encourage a transition to the signed shim bootloader. Partition image deploys avoid calling grub2-install with the preserve-efi-assets functions. Deploying whole disk images doesn't require grub2-install. This leaves whole disk images installed onto softraid devices, which still attempts to call grub2-install. This change will still attempt to run grub2-install in this one remaining case, but will ignore any failure. A future enhancement can avoid calling grub2-install entirely so that non-redhat secure-boot capable images can keep their signed bootloaders. Story: 2008923 Task: 42521 Change-Id: If432ef795d64d76442d739eb4f7d155ff847041e --- .../tests/unit/extensions/test_image.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ironic_python_agent/tests/unit') diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py index e2b633a7..599a1973 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -1675,6 +1675,21 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n mock_is_md_device, mock_execute, mock_dispatch): + # return success for every execute call + mock_execute.side_effect = [('', '')] * 21 + + # make grub2-install calls fail + grub_failure = processutils.ProcessExecutionError( + stdout='', + stderr='grub2-install: error: this utility cannot be used ' + 'for EFI platforms because it does not support ' + 'UEFI Secure Boot.\n', + exit_code=1, + cmd='grub2-install' + ) + mock_execute.side_effect[9] = grub_failure + mock_execute.side_effect[10] = grub_failure + mock_get_part_uuid.side_effect = [self.fake_root_part, self.fake_efi_system_part] environ_mock.get.return_value = '/sbin' @@ -1686,7 +1701,10 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n efi_system_part_uuid=self.fake_efi_system_part_uuid, target_boot_mode='uefi') - expected = [mock.call('mount', '/dev/fake2', self.fake_dir), + expected = [mock.call('partx', '-u', '/dev/fake', attempts=3, + delay_on_retry=True), + mock.call('udevadm', 'settle'), + mock.call('mount', '/dev/fake2', self.fake_dir), mock.call('mount', '-o', 'bind', '/dev', self.fake_dir + '/dev'), mock.call('mount', '-o', 'bind', '/proc', -- cgit v1.2.1