55 Commits

Author SHA1 Message Date
Fedor Tarasenko
694ea7425d Support using LABEL as identifier for rootfs
Add possibility to use disk LABEL to identify rootfs uuid for
Software RAID deployment

Change-Id: I77f36e70ddc539af0190db1c1abe0fb2c66f34b4
Story: 2008303
Task: 41188
2020-11-03 13:03:34 +03:00
Julia Kreger
6542a9cb04 Don't run os-prober from grub2-mkconfig
By default, grub2-mkconfig scans everything to look for other
environments and then load those into the grub configuration.

It makes sense, but on newer versions of grub2 in distribution
images, os-prober is taking an exceptionally long time in some
cases where more than one storage device exists with other
filesystems.

As a result, of the os-prober execution by grub2-mkconfig, the
bootloader installation can completely time out and fail the
deployment. This is presently experienced with metalsmith on
centos8.

There are numerous sporatic reports of issues like this issue
where grub2-mkconfig hangs for some period of time, and this is
observable on Centos8.2 in our CI. While one report[0] mentions
this issue, Another bug [1] has the dialog that actually helps us
frame the context as to what we likely should do.

Also, fixes the unit testing so we actually test if we're running
with grub2. :\

[0]: https://bugzilla.redhat.com/show_bug.cgi?id=1744693
[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1709682

Depends-On: https://review.opendev.org/#/c/748315
Change-Id: I14bf299afef3a1ddb2006fe5f182d7f0d249e734
2020-10-22 22:28:07 +00:00
Zuul
35d2292aa4 Merge "Log a warning of target_boot_mode does not match current boot mode" 2020-10-07 17:01:51 +00:00
Dmitry Tantsur
1a67dddde7 Log a warning of target_boot_mode does not match current boot mode
This is not a normal situation and is likely to cause problems.

Change-Id: Id0668fd160ac0539d85997e985f8c43d9da75c90
2020-10-07 12:30:23 +02:00
Dmitry Tantsur
fc4e0eed6a Don't try to call GRUB when root UUID is not provided
We don't have a really working way to detect root UUID for whole
disk images at the moment, which results in an ignored traceback
every time install_bootloader is called with whole disk images in
UEFI mode. Avoid it by skipping GRUB2 if root UUID is unknown.

Change-Id: I84245538f59c664b72d1cafbca8d61be0978f489
2020-10-07 12:06:42 +02:00
Zuul
dc395c5837 Merge "More refactoring of the image module" 2020-07-27 07:15:42 +00:00
Riccardo Pittau
80e11811f5 More refactoring of the image module
Introducing new function _umount_all_partitions to reduce the size
of _install_grub2

Change-Id: I304468d57b10d677f2a9d58aec42a1bf414c6cba
2020-07-24 14:34:46 +02:00
Julia Kreger
2a56ee03b6 Prevent un-needed iscsi cleanup
When we added software raid support, we started calling bootloader
installation. As time went on, we ehnanced that code path for non
RAID cases in order to ensure that UEFI nvram was setup
for the instance to boot properly.

Somewhere in this process, we missed a possible failure case where
the iscsi client tgtadm may return failures. Obviously, the correct
path is to not call iscsi teardown if we don't need to.

Since it was always semi-opportunistic teardown, we can't blindly
catch any error, and if we started iSCSI and failed to tear the
connection down, we might want to still fail, so this change
moves the logic over to use a flag on the agent object which
one extension to set the flag and the other to read it and take
action based upon that.

Change-Id: Id3b1ae5e59282f4109f6246d5614d44c93aefa7c
Story: 2007937
Task: 40395
2020-07-20 14:24:06 -07:00
Riccardo Pittau
9d9a6bce5c Refactor part of image module
Shuffle some functions around and reduce size of _is_bootloader_loaded
moving logic out to a new function.

Change-Id: I9c10bf05186dcebb37f175d61bf4ac9ff86b6510
2020-07-07 10:44:50 +02:00
Dmitry Tantsur
ba3caa6c64 Increase the ESP partition size to 550 MiB when using software RAID
This has been a popular guidance, and diskimage-builder has recently
started following it.

Change-Id: I794c846fb191c15b0a30546bf64d624dfbde0fd4
2020-07-02 17:30:33 +02:00
Zuul
de7d5affe7 Merge "Mount all vfat partitions before calling grub2" 2020-07-02 10:37:04 +00:00
Arne Wiebalck
c5022790b3 Mount all vfat partitions before calling grub2
In order to ensure grub2 finds all files it needs, mount all
vfat partitions specified in the deployed image.

Story: #2007618
Task: #39629
Change-Id: Ie5b6e0abc3f266409562f9ecb26538126b667056
2020-06-30 18:31:58 +02:00
Dmitry Tantsur
7e5fe1121e Make the install_bootloader command asynchronous
It does not return anything, so it makes no point for it to be
synchronous. Ironic always calls it with wait=True, so there is
no problem with backward compatibility either.

Change-Id: I44fec2e0cb54486328ce71263613d8592e384870
2020-06-08 15:10:05 +02:00
Arne Wiebalck
66c32784af Editing follow-up for UEFI Software RAID support
This is a follow-up to https://review.opendev.org/#/c/696156/

Change-Id: I0fd2c09045ff07a57374934c35d4a3a8467f5e99
Story: #2006379
Task: #37635
2020-04-06 18:03:25 +02:00
Raphael Glon
9343348106 Software RAID: Add UEFI support
The proposed changes concern two steps:

First, when creating the RAID configuration, have a GPT partition
table type (this is not necessary, but more natural with UEFI).
Also, leave some space, either for the EFI partitions or the BIOS
boot partitions, outside the Software RAID.

Secondly, when installing the bootloader, make sure the correct
boot partitions are created or relocated.

Change-Id: Icf0a76b0de89e7a8494363ec91b2f1afda4faa3b
Story: #2006379
Task: #37635
2020-04-02 18:02:19 +02:00
Zuul
68a71513f0 Merge "Bump hacking to 3.0.0" 2020-03-31 12:36:11 +00:00
Riccardo Pittau
a332a19a57 Bump hacking to 3.0.0
Change-Id: I1032ea6a2e9d79aeaecb1458c319cbeb15ac1fff
2020-03-30 12:55:46 +02:00
Julia Kreger
916cd5c8de 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
2020-03-29 14:47:41 +00:00
Julia Kreger
bf0bb7a87a Improve debug logging around Raid/Bootloader
Change-Id: I7d34b918a859972a2d5650494824d3333016dd11
2020-03-28 08:55:32 -07:00
Zuul
d73d27afbd Merge "[trivial] Fix comment for Software RAID restart" 2020-03-25 10:57:30 +00:00
Arne Wiebalck
46c482d063 [trivial] Fix comment for Software RAID restart
The detection of the holder disks was moved elsewhere,
so the comment is misleading now.

Change-Id: If41b4270ab8fb1626979ca17134764e088e3cb65
2020-03-23 18:54:46 +01:00
Julia Kreger
81137d4045 Return false for MBR bootloader check on UEFI machines
Somewhat common are dual boot images that have both a MBR loader
and the contents required for a UEFI boot, as largely the pointer
to where to begin reading the rest of the boot loader occurs in
the first few hundred bytes on disk which redirects the disk to
begin reading from a known address.

This goes sideways on UEFI machines where this method of booting
is not recognized nor supported. Thus we need to return false when
we encounter this state.

Change-Id: I8c0b42bb71b9e26ed7fec8894e21ce7fc06b94a1
Story: 2007455
Task: 39133
2020-03-23 10:41:04 -07:00
Julia Kreger
6f1f9c7f6e Rescan devices before performing uefi checks
With the fix to the uefi code path so secure boot works properly
and is not accidently stomped on, we forgot to rescan the device
and force the partition table to update, which is vital for iscsi
based deploys.

Depends-On: https://review.opendev.org/706960
Change-Id: Ic2f338be075e93a2ce8c76c706d37db9bf8792ea
Story: 2007276
Task: 38713
2020-03-16 05:57:54 -07:00
mvpnitesh
823a7cd9db Fixes error handling if efibootmgr is not present in ramdisk
Change-Id: I8edff252e72cb91282f8984cd6935f39cd744cfe
Story: 2007324
Task: 38842
2020-03-03 00:14:33 -06:00
Iury Gregory Melo Ferreira
b6210be196 Avoid grub2-install when on UEFI boot mode
This patch changes the workflow for whole disk images when using uefi.
If we can identify the bootloader and it's valid we can update using
efibootmgr since grub2-install have problems specially on secure boot
mode.
We also updated the regex to search for the uefi partition on the disk,
since in some cases the parted command output can be without the FS
for the partition with esp Flag.

Change-Id: I7167e71e5d2352a045565289b200e5530d0ba11d
Story: #2006847
Task: #37435
2020-01-16 11:23:41 +01:00
Arne Wiebalck
13a26553e5 Software RAID: Use UUID to find root fs
Rather than assuming that the root fs is in the first partition
of the deployed image, use the UUID passed from the conductor.

Change-Id: Ie2299372e94386902e0a8be0597250ec52e1fec9
Story: #2006649
Task: #36887
Depends-on: https://review.opendev.org/686580
2019-12-04 15:32:50 +01:00
Dmitry Tantsur
1d12505fa0 Do not try to read raw disk data as unicode
Fixes regression in commit 9f8fa2853af00045118ccd44180e7053e6d027af:
utils.execute returns unicode by default, but this data is binary.

Change-Id: I5b54c1f6cfac5fff672245c523b9fb647478edbd
2019-11-11 16:03:59 +01:00
Julia Kreger
9f8fa2853a Don't try to put a bootloader in place when bootable
Lets not do silly things and if the disk looks bootable,
and we're not trying to do UEFI, then let us assume the
proper thing will occur upon power-up.

Looks at the boot sector data and if an executable is
found in the first 218 bytes, then it bypasses loading
a boot loader.

Also adds a dependency on the "file" linux distribution
package.

Change-Id: I11bc26670a08ee13174a43d7cd0f1ab9c1bd35cf
Story: 2006474
Task: 36410
2019-11-01 13:58:55 +00:00
Zuul
358a46c4fe Merge "[Trivial]: Typo in comment for _get_partition" 2019-10-29 15:02:44 +00:00
Zuul
a158b862ea Merge "Set rd.md.uuid kernel parameter when deploying on software raid" 2019-10-28 11:43:04 +00:00
Arne Wiebalck
cb96cec794 [Trivial]: Typo in comment for _get_partition
Change-Id: I29a3ea86dd710fc206d9c25cb12b08324538d224
2019-10-25 18:48:16 +02:00
Andrei Nistor
1975478097 Set rd.md.uuid kernel parameter when deploying on software raid
When deploying an image to a software raid array, it is currently
required that the deployed image assembles the md arrays automatically
so that the rootfs can be mounted. In order to remove this
requirement/limitation on the deployed image we can add rd.md.uuid to
the kernel command line with the raid array's uuid.

Story: 2006648
Task: 36884
Change-Id: I42cb198753ecd84b7eaef6b5aa7c2064535bfe0e
2019-10-17 11:14:04 +00:00
Julia Kreger
3ee17e8624 Last resort fallback to find a partition
Falls back to attempt to use findfs to locate
a UUID or PARTUUID match as opposed to trying to
list and enumerate through lsblk output.

Can confirm that tinycore 8.x's findfs binary works
expected.

Story: 2006724
Task: 37141

Change-Id: I4d488e4a1ab680eb1353b158c3339cb30b056ada
2019-10-15 16:35:17 +00:00
Arne Wiebalck
3e2d3481a5 Software RAID: Check if install partition exists
The deployment on top of a software RAID goes to the first partition
of the md device. Raise an exception if that partition does not exist.

Follow-up to Ieb2c95ff130b5cc1e643fcde500066d9458ddbec

Change-Id: I2b4c835d57d3888e3325aee40e8319ef8683cd27
2019-06-07 14:51:02 +02:00
Zuul
3c91e55886 Merge "Software RAID: Add IPA deploy support" 2019-06-05 19:40:09 +00:00
Arne Wiebalck
8fe390ecdd Software RAID: Add IPA deploy support
This patch proposes to extend the IPA to be able to deploy on
software RAID devices. The IPA needs to be able to detect an
md device, find the underlying holder disks and configure grub
on them.

Change-Id: Ieb2c95ff130b5cc1e643fcde500066d9458ddbec
Story: #2004581
Task: #29102
2019-06-04 12:43:09 +02:00
Derek Higgins
9c35f02792 Bind mount /run into chroot when installing grub
grub-mkconfig runs a lvs command that attempts to access /run/lvm
once for each block device, currently it times out after 10 seconds
for each device and moves on. Multiple 10 second delays become
a problem (causing IPA API timeouts) when multiple block devices
are present. Bind mounting in /run avoids the delay and the
timeouts.

Task: 30616
Story: 2005507

Change-Id: Iae8b7808a35bff121f64971aadd4bd36b5f5bb71
2019-04-25 23:53:19 +01:00
Zuul
667589bb00 Merge "fall back to PARTUUID if UUID not found." 2018-08-03 15:40:51 +00:00
Matthew Thode
7e0bcbbeee fall back to PARTUUID if UUID not found.
Change-Id: Icbf1fd8179658bd8bcd15f99aaaee796288dbf6f
Story: 2002052
Task: 19714
2018-07-31 13:01:33 -07:00
Michael Turek
b32750f5c4 Install grub to PReP partition when prep_boot_part_uuid is provided
Installs the grub bootloader to the PreP Boot partition when the
prep_boot_partition_uuid is provided. This is required when
booting a partition image locally on ppc64* systems.

This change also passes the cpu_arch along to work_on_disk so
that the PReP partition is created when partitioning disks for
local boot on ppc64* systems,

Change-Id: I70667d43af962b357e6eeccba258f4fa5a91a09e
Depends-On: I2bc9f13ec605de7b7b96d96a1a4edebee0af76dc
Story: #1749057
Task: #22999
2018-07-20 16:07:16 +00:00
Dmitry Tantsur
db4694de24 Do not try unmounting the EFI partition if it was not mounted
If mounting the root partition fails for some reason, we try to unmount
the EFI partition, which is not mounted at this point. This results in
a new exception hiding the real failure. This change fixes it.

Change-Id: I0ec636a361eda71b4149e4a7ba1538a9bbf6ec34
Closes-Bug: #1732932
2017-12-14 19:52:53 -05:00
Vasyl Saienko
db5272cfea Remove hard-coded path to grub binaries
Use PATH variable to find grub binaries.

Closes-Bug: 1717255

Change-Id: Ic6a2bafdc87e33c4e1c4534fa355f995c824b945
2017-09-25 09:30:58 +03:00
Jenkins
7680625994 Merge "Use sh instead of bash when installing grub" 2017-01-18 10:27:56 +00:00
Pavlo Shchelokovskyy
a5370d52cd Use sh instead of bash when installing grub
there is no guarantee that 'bash' is present in a user's image,
while 'sh' as system shell must be there.
As we do not use any bash-specific syntax (just starting commands in a
subshell) when installing the bootloader from chroot-ed user image,
let's be more supportive and use 'sh' instead of 'bash' for that.

Change-Id: I1fb82068b9c55da35166d8d2ecf9f0ba41356adb
Closes-Bug: #1657096
2017-01-17 13:57:49 +02:00
Cao Xuan Hoang
6997907b07 Removes unnecessary utf-8 encoding
The following files added utf-8 encoding but never used. So we can
removes them at all.

ironic_python_agent/extensions/image.py
ironic_python_agent/extensions/iscsi.py
ironic_python_agent/tests/unit/extensions/test_image.py
ironic_python_agent/tests/unit/extensions/test_iscsi.py

Change-Id: Ifc98faf025ee81f885ea58d9203037c6357ea7f2
2017-01-16 08:25:10 +07:00
John L. Villalovos
0b8763e332 Update to hacking 0.12.0 and use new checks
Use hacking 0.12.0

Use the new checks that are available:
    [H106] Don’t put vim configuration in source files.
    [H203] Use assertIs(Not)None to check for None.
    [H904] Delay string interpolations at logging calls.

Fix code so tests pass.

Change-Id: If22ad272c332f30624ce10861408d377908b152b
Depends-On: I2aa44b62f900d4dfd67701b01eadd0523fbfaf07
2016-11-08 11:31:18 -08:00
Derek Higgins
cc5556d06b Install grub in the EFI "Fallback path"
In systems where the nvram may have been reset, add
\EFI\BOOT\BOOTx64.EFI to the EFI system partition so that
the image continues to boot. This will be particularly useful
if the NVRAM wasn't written correctly or if the baremetal
server is be simulated on virt and the NVRAM was been reset
on start (as is the case in libvirt).

Change-Id: I5005ae02c283cdc01540ea46c341a7b0bf9d4c42
Closes-Bug: #1632637
2016-10-20 13:50:02 +00:00
Nisha Agarwal
bb605784dd Fixes programmatic error in _install_grub()
The patch defines the variables before they are used in the
code.

Closes-bug: 1555547
Change-Id: I27c5e926cf4001211c4edd794a09b26559c63f71
2016-03-11 21:09:37 +00:00
Dmitry Tantsur
4cd64e28aa Delete the Linux-IO target before setting up local boot
Otherwise it fails with "device already mounted".

Change-Id: If959ba5a10e97f84be2f7498bed7589d13fa30c2
Closes-Bug: #1526304
2015-12-15 15:20:03 +01:00
Dan Prince
ebd7b076a5 Use mount -t sysfs to avoid host /sys dependencies
This patch updates the _install_grub2 function in image.py
so that we use 'mount -t sysfs' instead of bind mounting
the hosts /sys into the chroot.

This resolves issues which can occur with unmounting
the chroot mounts where 'target is busy' errors
may occur when you are debugging things with a serial
console.

Change-Id: I5c9a6546d048cbf54695329d9744fda55127bd30
Closes-bug: #1503385
2015-10-07 03:29:18 +00:00