diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 7ac1a4e33..f3eb97f61 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -62,7 +62,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 c97a1af7c..6e5c2a4ed 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -231,7 +231,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, @@ -278,7 +278,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, @@ -334,7 +334,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, @@ -395,7 +395,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, @@ -447,7 +447,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, @@ -1891,7 +1891,7 @@ Boot0004* ironic1 HD(1,GPT,55db8d03-c8f6-4a5b-9155-790dddc348fa,0x800,0x640 efi_system_part_uuid=self.fake_efi_system_part_uuid, target_boot_mode='uefi') - 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', '/dev/fake2', self.fake_dir), @@ -2066,7 +2066,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,LABEL', @@ -2090,7 +2090,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,LABEL', @@ -2113,7 +2113,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,LABEL', @@ -2133,7 +2133,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,LABEL', @@ -2153,7 +2153,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,LABEL', @@ -2172,7 +2172,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,LABEL', @@ -2286,7 +2286,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, @@ -2341,7 +2341,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, @@ -2383,7 +2383,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', @@ -2423,7 +2423,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 000000000..05dee911a --- /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.