Browse Source

Re-read the partition table with partx -a, part 2

Use add instead of update to re-read the partition table with partx.

See [1] for more details.

Co-authored-by: Arne Wiebalck <arne.wiebalck@cern.ch>

[1] https: //opendev.org/openstack/ironic-python-agent/commit/dc8c1f16f9a00e2bff21612d1a9cf0ea0f3addf0

Change-Id: I2336e22dadc790cfbde87904612fcaa3b8c501db
(cherry picked from commit 23e67b5fea)
(cherry picked from commit 56e63ce36a)
changes/86/821786/1 ussuri-em
Riccardo Pittau 7 months ago committed by Steve Baker
parent
commit
dc62636c17
  1. 2
      ironic_python_agent/hardware.py
  2. 84
      ironic_python_agent/tests/unit/test_hardware.py
  3. 7
      releasenotes/notes/fix-rescan-device-raid-29aa1558b036b496.yaml

2
ironic_python_agent/hardware.py

@ -1780,7 +1780,7 @@ class GenericHardwareManager(HardwareManager):
# The real difference between partx and partprobe is
# unclear, but note that partprobe does not seem to
# work synchronously for nvme drives...
utils.execute("partx", "-u", device,
utils.execute("partx", "-a", device,
check_exit_code=False)
except processutils.ProcessExecutionError as e:
msg = "Failed to create partitions on {}: {}".format(

84
ironic_python_agent/tests/unit/test_hardware.py

@ -3164,16 +3164,16 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('sgdisk', '-F', '/dev/sdb'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 2,
'/dev/sda1', '/dev/sdb1'),
@ -3246,22 +3246,22 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('sgdisk', '-F', '/dev/sdc'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sdc', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdc', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdc', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sdc', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdc', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdc', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 3,
'/dev/sda1', '/dev/sdb1', '/dev/sdc1'),
@ -3337,28 +3337,28 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('sgdisk', '-F', '/dev/sdd'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sdc', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdc', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdc', check_exit_code=False),
mock.call('parted', '/dev/sdd', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdd', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdd', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sdc', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdc', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdc', check_exit_code=False),
mock.call('parted', '/dev/sdd', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdd', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdd', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 4,
'/dev/sda1', '/dev/sdb1', '/dev/sdc1', '/dev/sdd1'),
@ -3414,16 +3414,16 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('parted', '/dev/sdb', '-s', '--', 'mklabel', 'gpt'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '551MiB', '10GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '551MiB', '10GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 2,
'/dev/sda1', '/dev/sdb1'),
@ -3485,16 +3485,16 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('parted', '/dev/sdb', '-s', '--', 'mklabel', 'gpt'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '8MiB', '10GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '8MiB', '10GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 2,
'/dev/sda1', '/dev/sdb1'),
@ -3552,16 +3552,16 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('sgdisk', '-F', '/dev/sdb'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '30GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '30GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 2,
'/dev/sda1', '/dev/sdb1'),
@ -3620,16 +3620,16 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('sgdisk', '-F', '/dev/sdb'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '20GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '20GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '20GiB', '-1'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '20GiB', '-1'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '0', '--raid-devices', 2,
'/dev/sda1', '/dev/sdb1'),
@ -3699,16 +3699,16 @@ class TestGenericHardwareManager(base.IronicAgentTest):
mock.call('sgdisk', '-F', '/dev/sdb'),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '42s', '10GiB'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('parted', '/dev/sda', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sda', check_exit_code=False),
mock.call('partx', '-a', '/dev/sda', check_exit_code=False),
mock.call('parted', '/dev/sdb', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/sdb', check_exit_code=False),
mock.call('partx', '-a', '/dev/sdb', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 2,
'/dev/sda1', '/dev/sdb1'),
@ -4029,16 +4029,16 @@ class TestGenericHardwareManager(base.IronicAgentTest):
'gpt'),
mock.call('parted', '/dev/nvme0n1', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '551MiB', '10GiB'),
mock.call('partx', '-u', '/dev/nvme0n1', check_exit_code=False),
mock.call('partx', '-a', '/dev/nvme0n1', check_exit_code=False),
mock.call('parted', '/dev/nvme1n1', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '551MiB', '10GiB'),
mock.call('partx', '-u', '/dev/nvme1n1', check_exit_code=False),
mock.call('partx', '-a', '/dev/nvme1n1', check_exit_code=False),
mock.call('parted', '/dev/nvme0n1', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/nvme0n1', check_exit_code=False),
mock.call('partx', '-a', '/dev/nvme0n1', check_exit_code=False),
mock.call('parted', '/dev/nvme1n1', '-s', '-a', 'optimal', '--',
'mkpart', 'primary', '10GiB', '-1'),
mock.call('partx', '-u', '/dev/nvme1n1', check_exit_code=False),
mock.call('partx', '-a', '/dev/nvme1n1', check_exit_code=False),
mock.call('mdadm', '--create', '/dev/md0', '--force', '--run',
'--metadata=1', '--level', '1', '--raid-devices', 2,
'/dev/nvme0n1p1', '/dev/nvme1n1p1'),

7
releasenotes/notes/fix-rescan-device-raid-29aa1558b036b496.yaml

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes an issue where partitions are not visible due to an
incorrect call to have the partition table re-read during raid
configuration creation.
Loading…
Cancel
Save