Skip to content

Commit 8c88a40

Browse files
committed
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 dc8c1f1)
1 parent c916478 commit 8c88a40

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

ironic_python_agent/extensions/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _rescan_device(device):
6262
kernel partition records.
6363
"""
6464
try:
65-
utils.execute('partx', '-u', device, attempts=3,
65+
utils.execute('partx', '-a', device, attempts=3,
6666
delay_on_retry=True)
6767
utils.execute('udevadm', 'settle')
6868
except processutils.ProcessExecutionError:

ironic_python_agent/tests/unit/extensions/test_image.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def test__uefi_bootloader_given_partition(
231231
('', ''), ('', '')])
232232

233233
expected = [mock.call('efibootmgr', '--version'),
234-
mock.call('partx', '-u', '/dev/fake', attempts=3,
234+
mock.call('partx', '-a', '/dev/fake', attempts=3,
235235
delay_on_retry=True),
236236
mock.call('udevadm', 'settle'),
237237
mock.call('mount', self.fake_efi_system_part,
@@ -278,7 +278,7 @@ def test__uefi_bootloader_find_partition(
278278
('', ''), ('', '')])
279279

280280
expected = [mock.call('efibootmgr', '--version'),
281-
mock.call('partx', '-u', '/dev/fake', attempts=3,
281+
mock.call('partx', '-a', '/dev/fake', attempts=3,
282282
delay_on_retry=True),
283283
mock.call('udevadm', 'settle'),
284284
mock.call('mount', self.fake_efi_system_part,
@@ -334,7 +334,7 @@ def test__uefi_bootloader_with_entry_removal(
334334
('', ''), ('', '')])
335335

336336
expected = [mock.call('efibootmgr', '--version'),
337-
mock.call('partx', '-u', '/dev/fake', attempts=3,
337+
mock.call('partx', '-a', '/dev/fake', attempts=3,
338338
delay_on_retry=True),
339339
mock.call('udevadm', 'settle'),
340340
mock.call('mount', self.fake_efi_system_part,
@@ -395,7 +395,7 @@ def test__uefi_bootloader_with_entry_removal_lenovo(
395395
('', ''), ('', ''),
396396
('', ''), ('', '')])
397397
expected = [mock.call('efibootmgr', '--version'),
398-
mock.call('partx', '-u', '/dev/fake', attempts=3,
398+
mock.call('partx', '-a', '/dev/fake', attempts=3,
399399
delay_on_retry=True),
400400
mock.call('udevadm', 'settle'),
401401
mock.call('mount', self.fake_efi_system_part,
@@ -447,7 +447,7 @@ def test__add_multi_bootloaders(
447447
('', '')])
448448

449449
expected = [mock.call('efibootmgr', '--version'),
450-
mock.call('partx', '-u', '/dev/fake', attempts=3,
450+
mock.call('partx', '-a', '/dev/fake', attempts=3,
451451
delay_on_retry=True),
452452
mock.call('udevadm', 'settle'),
453453
mock.call('mount', self.fake_efi_system_part,
@@ -1891,7 +1891,7 @@ def test__install_grub2_softraid_uefi_gpt(
18911891
efi_system_part_uuid=self.fake_efi_system_part_uuid,
18921892
target_boot_mode='uefi')
18931893

1894-
expected = [mock.call('partx', '-u', '/dev/fake', attempts=3,
1894+
expected = [mock.call('partx', '-a', '/dev/fake', attempts=3,
18951895
delay_on_retry=True),
18961896
mock.call('udevadm', 'settle'),
18971897
mock.call('mount', '/dev/fake2', self.fake_dir),
@@ -2066,7 +2066,7 @@ def test__get_partition(self, mock_is_md_device, mock_is_bootloader,
20662066

20672067
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
20682068
self.assertEqual('/dev/test2', root_part)
2069-
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
2069+
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
20702070
delay_on_retry=True),
20712071
mock.call('udevadm', 'settle'),
20722072
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@@ -2090,7 +2090,7 @@ def test__get_partition_no_device_found(self, mock_is_md_device,
20902090
self.assertRaises(errors.DeviceNotFound,
20912091
image._get_partition, self.fake_dev,
20922092
self.fake_root_uuid)
2093-
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
2093+
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
20942094
delay_on_retry=True),
20952095
mock.call('udevadm', 'settle'),
20962096
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@@ -2113,7 +2113,7 @@ def test__get_partition_fallback_partuuid(self, mock_is_md_device,
21132113

21142114
result = image._get_partition(self.fake_dev, self.fake_root_uuid)
21152115
self.assertEqual('/dev/loop0', result)
2116-
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
2116+
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
21172117
delay_on_retry=True),
21182118
mock.call('udevadm', 'settle'),
21192119
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@@ -2133,7 +2133,7 @@ def test__get_partition_command_fail(self, mock_is_md_device,
21332133
image._get_partition, self.fake_dev,
21342134
self.fake_root_uuid)
21352135

2136-
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
2136+
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
21372137
delay_on_retry=True),
21382138
mock.call('udevadm', 'settle'),
21392139
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@@ -2153,7 +2153,7 @@ def test__get_partition_partuuid(self, mock_is_md_device, mock_execute,
21532153

21542154
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
21552155
self.assertEqual('/dev/test2', root_part)
2156-
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
2156+
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
21572157
delay_on_retry=True),
21582158
mock.call('udevadm', 'settle'),
21592159
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@@ -2172,7 +2172,7 @@ def test__get_partition_label(self, mock_is_md_device, mock_execute,
21722172

21732173
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
21742174
self.assertEqual('/dev/test2', root_part)
2175-
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
2175+
expected = [mock.call('partx', '-a', self.fake_dev, attempts=3,
21762176
delay_on_retry=True),
21772177
mock.call('udevadm', 'settle'),
21782178
mock.call('lsblk', '-PbioKNAME,UUID,PARTUUID,TYPE,LABEL',
@@ -2286,7 +2286,7 @@ def test__manage_uefi(self, mkdir_mock, mock_utils_efi_part,
22862286
('', ''), ('', ''),
22872287
('', '')])
22882288

2289-
expected = [mock.call('partx', '-u', '/dev/fake', attempts=3,
2289+
expected = [mock.call('partx', '-a', '/dev/fake', attempts=3,
22902290
delay_on_retry=True),
22912291
mock.call('udevadm', 'settle'),
22922292
mock.call('mount', self.fake_efi_system_part,
@@ -2341,7 +2341,7 @@ def test__manage_uefi_found_csv(self, mkdir_mock, mock_utils_efi_part,
23412341
('', ''), ('', ''),
23422342
('', '')])
23432343

2344-
expected = [mock.call('partx', '-u', '/dev/fake', attempts=3,
2344+
expected = [mock.call('partx', '-a', '/dev/fake', attempts=3,
23452345
delay_on_retry=True),
23462346
mock.call('udevadm', 'settle'),
23472347
mock.call('mount', self.fake_efi_system_part,
@@ -2383,7 +2383,7 @@ def test__manage_uefi_nvme_device(self, mkdir_mock, mock_utils_efi_part,
23832383
('', ''), ('', ''),
23842384
('', '')])
23852385

2386-
expected = [mock.call('partx', '-u', '/dev/fakenvme0', attempts=3,
2386+
expected = [mock.call('partx', '-a', '/dev/fakenvme0', attempts=3,
23872387
delay_on_retry=True),
23882388
mock.call('udevadm', 'settle'),
23892389
mock.call('mount', '/dev/fakenvme0p1',
@@ -2423,7 +2423,7 @@ def test__manage_uefi_wholedisk(
24232423
('', ''), ('', ''),
24242424
('', '')])
24252425

2426-
expected = [mock.call('partx', '-u', '/dev/fake', attempts=3,
2426+
expected = [mock.call('partx', '-a', '/dev/fake', attempts=3,
24272427
delay_on_retry=True),
24282428
mock.call('udevadm', 'settle'),
24292429
mock.call('mount', self.fake_efi_system_part,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fixes an issue where partitions are not visible due to a
5+
incorrect call to have the partition table re-read.

0 commit comments

Comments
 (0)