diff options
author | Arne Wiebalck <Arne.Wiebalck@cern.ch> | 2021-11-06 13:28:06 +0100 |
---|---|---|
committer | Steve Baker <sbaker@redhat.com> | 2021-12-16 09:09:09 +1300 |
commit | 06cf7f3d0c0492b1ade2574cddf42cfe4415ff00 (patch) | |
tree | 80bbff9cae8d535f459aabf79dca5ea4b1ff65a7 | |
parent | 9525a115284bbba19372085a33ac17a44d863e2c (diff) | |
download | ironic-python-agent-06cf7f3d0c0492b1ade2574cddf42cfe4415ff00.tar.gz |
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 dc8c1f16f9a00e2bff21612d1a9cf0ea0f3addf0)
(cherry picked from commit ab3e8a75badf2719602b2416af9e3c19d7511c79)
-rw-r--r-- | ironic_python_agent/extensions/image.py | 2 | ||||
-rw-r--r-- | ironic_python_agent/tests/unit/extensions/test_image.py | 28 | ||||
-rw-r--r-- | releasenotes/notes/fix-rescan-device-7b00c6836b687ce8.yaml | 5 |
3 files changed, 20 insertions, 15 deletions
diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 105dda78..7dc8b817 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -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: diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py index 898ff107..e730b7c9 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -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, @@ -359,7 +359,7 @@ Boot0002 VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51) ('', ''), ('', '')]) 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, @@ -421,7 +421,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 ('', ''), ('', ''), ('', ''), ('', '')]) 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, @@ -474,7 +474,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 ('', '')]) 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, @@ -1978,7 +1978,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 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', @@ -2002,7 +2002,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 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', @@ -2025,7 +2025,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 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', @@ -2045,7 +2045,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 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', @@ -2064,7 +2064,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 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', @@ -2178,7 +2178,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 ('', ''), ('', ''), ('', '')]) - 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, @@ -2233,7 +2233,7 @@ Boot0002: VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51) ('', ''), ('', ''), ('', '')]) - 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, @@ -2275,7 +2275,7 @@ Boot0002: VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51) ('', ''), ('', ''), ('', '')]) - 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', @@ -2315,7 +2315,7 @@ Boot0002: VENDMAGIC FvFile(9f3c6294-bf9b-4208-9808-be45dfc34b51) ('', ''), ('', ''), ('', '')]) - 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, diff --git a/releasenotes/notes/fix-rescan-device-7b00c6836b687ce8.yaml b/releasenotes/notes/fix-rescan-device-7b00c6836b687ce8.yaml new file mode 100644 index 00000000..05dee911 --- /dev/null +++ b/releasenotes/notes/fix-rescan-device-7b00c6836b687ce8.yaml @@ -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. |