Re-read the partition table with partx -a

Re-read the partition table with 'partx -a', rather than 'partx -u'.

This should fix an timing issue where the bootloader installation
fails to mount the EFI partition from a whole disk image since it
is not yet aware of the new partitions (observed with both, the
iscsi and the direct deploy interface).

Change-Id: If5da3075e813ae01df3decf8f0647aba111b0515
(cherry picked from commit dc8c1f16f9)
This commit is contained in:
Arne Wiebalck 2021-11-06 13:28:06 +01:00
parent 60a51252f4
commit ab3e8a75ba
3 changed files with 20 additions and 15 deletions

View File

@ -63,7 +63,7 @@ def _rescan_device(device):
kernel partition records.
"""
try:
utils.execute('partx', '-u', device, attempts=3,
utils.execute('partx', '-a', device, attempts=3,
delay_on_retry=True)
utils.execute('udevadm', 'settle')
except processutils.ProcessExecutionError:

View File

@ -254,7 +254,7 @@ class TestImageExtension(base.IronicAgentTest):
('', ''), ('', '')])
expected = [mock.call('efibootmgr', '--version'),
mock.call('partx', '-u', '/dev/fake', attempts=3,
mock.call('partx', '-a', '/dev/fake', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', self.fake_efi_system_part,
@ -302,7 +302,7 @@ class TestImageExtension(base.IronicAgentTest):
('', ''), ('', '')])
expected = [mock.call('efibootmgr', '--version'),
mock.call('partx', '-u', '/dev/fake', attempts=3,
mock.call('partx', '-a', '/dev/fake', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', self.fake_efi_system_part,
@ -355,7 +355,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
('', ''), ('', '')])
expected = [mock.call('efibootmgr', '--version'),
mock.call('partx', '-u', '/dev/fake', attempts=3,
mock.call('partx', '-a', '/dev/fake', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', self.fake_efi_system_part,
@ -408,7 +408,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
('', '')])
expected = [mock.call('efibootmgr', '--version'),
mock.call('partx', '-u', '/dev/fake', attempts=3,
mock.call('partx', '-a', '/dev/fake', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', self.fake_efi_system_part,
@ -1917,7 +1917,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
self.assertEqual('/dev/test2', root_part)
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@ -1941,7 +1941,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
self.assertRaises(errors.DeviceNotFound,
image._get_partition, self.fake_dev,
self.fake_root_uuid)
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@ -1964,7 +1964,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
result = image._get_partition(self.fake_dev, self.fake_root_uuid)
self.assertEqual('/dev/loop0', result)
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@ -1984,7 +1984,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
image._get_partition, self.fake_dev,
self.fake_root_uuid)
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@ -2004,7 +2004,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
self.assertEqual('/dev/test2', root_part)
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@ -2023,7 +2023,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
self.assertEqual('/dev/test2', root_part)
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@ -2137,7 +2137,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
('', ''), ('', ''),
('', '')])
expected = [mock.call('partx', '-u', '/dev/fake', attempts=3,
expected = [mock.call('partx', '-a', '/dev/fake', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', self.fake_efi_system_part,
@ -2181,7 +2181,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
('', ''), ('', ''),
('', '')])
expected = [mock.call('partx', '-u', '/dev/fake', attempts=3,
expected = [mock.call('partx', '-a', '/dev/fake', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', self.fake_efi_system_part,
@ -2221,7 +2221,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
('', ''), ('', ''),
('', '')])
expected = [mock.call('partx', '-u', '/dev/fakenvme0', attempts=3,
expected = [mock.call('partx', '-a', '/dev/fakenvme0', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', '/dev/fakenvme0p1',
@ -2261,7 +2261,7 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n
('', ''), ('', ''),
('', '')])
expected = [mock.call('partx', '-u', '/dev/fake', attempts=3,
expected = [mock.call('partx', '-a', '/dev/fake', attempts=3,
delay_on_retry=True),
mock.call('udevadm', 'settle'),
mock.call('mount', self.fake_efi_system_part,

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixes an issue where partitions are not visible due to a
incorrect call to have the partition table re-read.