Merge "Ignore efi grub2-install failure" into stable/wallaby
This commit is contained in:
@@ -706,34 +706,38 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None,
|
|||||||
utils.execute('mount', efi_partition,
|
utils.execute('mount', efi_partition,
|
||||||
efi_partition_mount_point)
|
efi_partition_mount_point)
|
||||||
efi_mounted = True
|
efi_mounted = True
|
||||||
# FIXME(rg): does not work in cross boot mode case (target
|
try:
|
||||||
# boot mode differs from ramdisk one)
|
utils.execute('chroot %(path)s /bin/sh -c '
|
||||||
# Probe for the correct target (depends on the arch, example
|
'"%(bin)s-install"' %
|
||||||
# --target=x86_64-efi)
|
{'path': path, 'bin': binary_name},
|
||||||
utils.execute('chroot %(path)s /bin/sh -c '
|
shell=True,
|
||||||
'"%(bin)s-install"' %
|
env_variables={
|
||||||
{'path': path, 'bin': binary_name},
|
'PATH': path_variable
|
||||||
shell=True,
|
})
|
||||||
env_variables={
|
except processutils.ProcessExecutionError as e:
|
||||||
'PATH': path_variable
|
LOG.warning('Ignoring GRUB2 boot loader installation failure: '
|
||||||
})
|
'%s.', e)
|
||||||
# Also run grub-install with --removable, this installs grub to
|
try:
|
||||||
# the EFI fallback path. Useful if the NVRAM wasn't written
|
# Also run grub-install with --removable, this installs grub to
|
||||||
# correctly, was reset or if testing with virt as libvirt
|
# the EFI fallback path. Useful if the NVRAM wasn't written
|
||||||
# resets the NVRAM on instance start.
|
# correctly, was reset or if testing with virt as libvirt
|
||||||
# This operation is essentially a copy operation. Use of the
|
# resets the NVRAM on instance start.
|
||||||
# --removable flag, per the grub-install source code changes
|
# This operation is essentially a copy operation. Use of the
|
||||||
# the default file to be copied, destination file name, and
|
# --removable flag, per the grub-install source code changes
|
||||||
# prevents NVRAM from being updated.
|
# the default file to be copied, destination file name, and
|
||||||
# We only run grub2_install for uefi if we can't verify the
|
# prevents NVRAM from being updated.
|
||||||
# uefi bits
|
# We only run grub2_install for uefi if we can't verify the
|
||||||
utils.execute('chroot %(path)s /bin/sh -c '
|
# uefi bits
|
||||||
'"%(bin)s-install --removable"' %
|
utils.execute('chroot %(path)s /bin/sh -c '
|
||||||
{'path': path, 'bin': binary_name},
|
'"%(bin)s-install --removable"' %
|
||||||
shell=True,
|
{'path': path, 'bin': binary_name},
|
||||||
env_variables={
|
shell=True,
|
||||||
'PATH': path_variable
|
env_variables={
|
||||||
})
|
'PATH': path_variable
|
||||||
|
})
|
||||||
|
except processutils.ProcessExecutionError as e:
|
||||||
|
LOG.warning('Ignoring GRUB2 boot loader installation failure: '
|
||||||
|
'%s.', e)
|
||||||
utils.execute('umount', efi_partition_mount_point, attempts=3,
|
utils.execute('umount', efi_partition_mount_point, attempts=3,
|
||||||
delay_on_retry=True)
|
delay_on_retry=True)
|
||||||
efi_mounted = False
|
efi_mounted = False
|
||||||
|
|||||||
@@ -1842,6 +1842,21 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
|
|||||||
mock_is_md_device,
|
mock_is_md_device,
|
||||||
mock_execute, mock_dispatch):
|
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,
|
mock_get_part_uuid.side_effect = [self.fake_root_part,
|
||||||
self.fake_efi_system_part]
|
self.fake_efi_system_part]
|
||||||
environ_mock.get.return_value = '/sbin'
|
environ_mock.get.return_value = '/sbin'
|
||||||
@@ -1853,7 +1868,10 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640
|
|||||||
efi_system_part_uuid=self.fake_efi_system_part_uuid,
|
efi_system_part_uuid=self.fake_efi_system_part_uuid,
|
||||||
target_boot_mode='uefi')
|
target_boot_mode='uefi')
|
||||||
|
|
||||||
expected = [mock.call('mount', '/dev/fake2', self.fake_dir),
|
expected = [mock.call('partx', '-a', '/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',
|
mock.call('mount', '-o', 'bind', '/dev',
|
||||||
self.fake_dir + '/dev'),
|
self.fake_dir + '/dev'),
|
||||||
mock.call('mount', '-o', 'bind', '/proc',
|
mock.call('mount', '-o', 'bind', '/proc',
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
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 calls
|
||||||
|
grub2-install. Running grub2-install is still attempted in this one
|
||||||
|
remaining case, but any failures are now ignored.
|
||||||
Reference in New Issue
Block a user