Swap partprobe and udev settle
On ubuntu based systems calling these in opposite causes a race condition where partitions aren't ready when we read/use them Closes-Bug: 2050013 Change-Id: Ied7e4f17786dfc0e7f54962013e48ff96c5faa88
This commit is contained in:
parent
118da00f2f
commit
ae53e8e4b3
@ -700,6 +700,7 @@ def trigger_device_rescan(device, attempts=None):
|
|||||||
# kernel.
|
# kernel.
|
||||||
udev_settle()
|
udev_settle()
|
||||||
partprobe(device, attempts=attempts)
|
partprobe(device, attempts=attempts)
|
||||||
|
udev_settle()
|
||||||
try:
|
try:
|
||||||
# Also verify that the partitioning is correct now.
|
# Also verify that the partitioning is correct now.
|
||||||
utils.execute('sgdisk', '-v', device, run_as_root=True)
|
utils.execute('sgdisk', '-v', device, run_as_root=True)
|
||||||
|
@ -260,6 +260,7 @@ class MakePartitionsTestCase(base.IronicLibTestCase):
|
|||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('partprobe', self.dev, attempts=10,
|
mock.call('partprobe', self.dev, attempts=10,
|
||||||
run_as_root=True),
|
run_as_root=True),
|
||||||
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('sgdisk', '-v', self.dev, run_as_root=True)]
|
mock.call('sgdisk', '-v', self.dev, run_as_root=True)]
|
||||||
|
|
||||||
mock_exc.assert_has_calls([parted_call, fuser_call] + sync_calls)
|
mock_exc.assert_has_calls([parted_call, fuser_call] + sync_calls)
|
||||||
@ -730,6 +731,7 @@ class TriggerDeviceRescanTestCase(base.IronicLibTestCase):
|
|||||||
mock.call('sync'),
|
mock.call('sync'),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('partprobe', '/dev/fake', run_as_root=True, attempts=10),
|
mock.call('partprobe', '/dev/fake', run_as_root=True, attempts=10),
|
||||||
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('sgdisk', '-v', '/dev/fake', run_as_root=True),
|
mock.call('sgdisk', '-v', '/dev/fake', run_as_root=True),
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -740,11 +742,12 @@ class TriggerDeviceRescanTestCase(base.IronicLibTestCase):
|
|||||||
mock.call('sync'),
|
mock.call('sync'),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('partprobe', '/dev/fake', run_as_root=True, attempts=1),
|
mock.call('partprobe', '/dev/fake', run_as_root=True, attempts=1),
|
||||||
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('sgdisk', '-v', '/dev/fake', run_as_root=True),
|
mock.call('sgdisk', '-v', '/dev/fake', run_as_root=True),
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_fails(self, mock_execute):
|
def test_fails(self, mock_execute):
|
||||||
mock_execute.side_effect = [('', '')] * 3 + [
|
mock_execute.side_effect = [('', '')] * 4 + [
|
||||||
processutils.ProcessExecutionError
|
processutils.ProcessExecutionError
|
||||||
]
|
]
|
||||||
self.assertFalse(disk_utils.trigger_device_rescan('/dev/fake'))
|
self.assertFalse(disk_utils.trigger_device_rescan('/dev/fake'))
|
||||||
@ -752,6 +755,7 @@ class TriggerDeviceRescanTestCase(base.IronicLibTestCase):
|
|||||||
mock.call('sync'),
|
mock.call('sync'),
|
||||||
mock.call('udevadm', 'settle'),
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('partprobe', '/dev/fake', run_as_root=True, attempts=10),
|
mock.call('partprobe', '/dev/fake', run_as_root=True, attempts=10),
|
||||||
|
mock.call('udevadm', 'settle'),
|
||||||
mock.call('sgdisk', '-v', '/dev/fake', run_as_root=True),
|
mock.call('sgdisk', '-v', '/dev/fake', run_as_root=True),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user