From 916cd5c8de911a58b8a6769c32983d4f8d2d7f55 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Fri, 7 Feb 2020 14:39:29 -0800 Subject: [PATCH] Rescan after restarting the md device If an md device is restarted, there is a chance, depending on the OS, that the partition may not be found upon start of the md device. Instead, we should always rescan after re-assembling the raid device. Story: 2007275 Task: 38712 Change-Id: I92bac20812940e04381a54ef2905ef5f6e293813 --- ironic_python_agent/extensions/image.py | 13 ++++++++++++- releasenotes/notes/md-restart-9e0d47863a086792.yaml | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/md-restart-9e0d47863a086792.yaml diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 67497170f..b110b78b2 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -351,15 +351,26 @@ def _install_grub2(device, root_uuid, efi_system_part_uuid=None, prep_boot_part_uuid=None): """Install GRUB2 bootloader on a given device.""" LOG.debug("Installing GRUB2 bootloader on device %s", device) - root_partition = _get_partition(device, uuid=root_uuid) + efi_partition = None efi_partition_mount_point = None efi_mounted = False + # NOTE(TheJulia): Seems we need to get this before ever possibly + # restart the device in the case of multi-device RAID as pyudev + # doesn't exactly like the partition disappearing. + root_partition = _get_partition(device, uuid=root_uuid) + + # If the root device is an md device (or partition), restart the device + # (to help grub finding it) and identify the underlying holder disks + # to install grub. if hardware.is_md_device(device): # If the root device is an md device (or partition), # restart the device to help grub find it later on. hardware.md_restart(device) + # If an md device, we need to rescan the devices anyway to pickup + # the md device partition. + _rescan_device(device) elif (_is_bootloader_loaded(device) and not (efi_system_part_uuid or prep_boot_part_uuid)): diff --git a/releasenotes/notes/md-restart-9e0d47863a086792.yaml b/releasenotes/notes/md-restart-9e0d47863a086792.yaml new file mode 100644 index 000000000..a050bd04e --- /dev/null +++ b/releasenotes/notes/md-restart-9e0d47863a086792.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Rescans partitions on a software RAID device that gets restarted when + installing boot loader.