Add retry attempts for the partprobe command
The partprobe command may fail because the device is busy some times. Add retry attempts to resolve this problem. Closes-Bug: #1756760 Change-Id: Ic888e7b6c93e83511a76bf8000619531b1eec9e1
This commit is contained in:
parent
cdea1086d6
commit
d2ade05278
|
@ -55,6 +55,10 @@ opts = [
|
||||||
default=3,
|
default=3,
|
||||||
help='Maximum attempts to verify an iSCSI connection is '
|
help='Maximum attempts to verify an iSCSI connection is '
|
||||||
'active, sleeping 1 second between attempts.'),
|
'active, sleeping 1 second between attempts.'),
|
||||||
|
cfg.IntOpt('partprobe_attempts',
|
||||||
|
default=10,
|
||||||
|
help='Maximum number of attempts to try to read the '
|
||||||
|
'partition.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
@ -627,7 +631,8 @@ def _get_labelled_partition(device_path, label, node_uuid):
|
||||||
returns None.
|
returns None.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
utils.execute('partprobe', device_path, run_as_root=True)
|
utils.execute('partprobe', device_path, run_as_root=True,
|
||||||
|
attempts=CONF.disk_utils.partprobe_attempts)
|
||||||
|
|
||||||
# lsblk command
|
# lsblk command
|
||||||
output, err = utils.execute('lsblk', '-Po', 'name,label', device_path,
|
output, err = utils.execute('lsblk', '-Po', 'name,label', device_path,
|
||||||
|
|
|
@ -828,7 +828,7 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase):
|
||||||
self.node_uuid)
|
self.node_uuid)
|
||||||
self.assertEqual(part_result, result)
|
self.assertEqual(part_result, result)
|
||||||
execute_calls = [
|
execute_calls = [
|
||||||
mock.call('partprobe', self.dev, run_as_root=True),
|
mock.call('partprobe', self.dev, run_as_root=True, attempts=10),
|
||||||
mock.call('lsblk', '-Po', 'name,label', self.dev,
|
mock.call('lsblk', '-Po', 'name,label', self.dev,
|
||||||
check_exit_code=[0, 1],
|
check_exit_code=[0, 1],
|
||||||
use_standard_locale=True, run_as_root=True)
|
use_standard_locale=True, run_as_root=True)
|
||||||
|
@ -843,7 +843,7 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase):
|
||||||
self.node_uuid)
|
self.node_uuid)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
execute_calls = [
|
execute_calls = [
|
||||||
mock.call('partprobe', self.dev, run_as_root=True),
|
mock.call('partprobe', self.dev, run_as_root=True, attempts=10),
|
||||||
mock.call('lsblk', '-Po', 'name,label', self.dev,
|
mock.call('lsblk', '-Po', 'name,label', self.dev,
|
||||||
check_exit_code=[0, 1],
|
check_exit_code=[0, 1],
|
||||||
use_standard_locale=True, run_as_root=True)
|
use_standard_locale=True, run_as_root=True)
|
||||||
|
@ -861,7 +861,7 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase):
|
||||||
disk_utils._get_labelled_partition, self.dev,
|
disk_utils._get_labelled_partition, self.dev,
|
||||||
self.config_part_label, self.node_uuid)
|
self.config_part_label, self.node_uuid)
|
||||||
execute_calls = [
|
execute_calls = [
|
||||||
mock.call('partprobe', self.dev, run_as_root=True),
|
mock.call('partprobe', self.dev, run_as_root=True, attempts=10),
|
||||||
mock.call('lsblk', '-Po', 'name,label', self.dev,
|
mock.call('lsblk', '-Po', 'name,label', self.dev,
|
||||||
check_exit_code=[0, 1],
|
check_exit_code=[0, 1],
|
||||||
use_standard_locale=True, run_as_root=True)
|
use_standard_locale=True, run_as_root=True)
|
||||||
|
@ -875,8 +875,8 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase):
|
||||||
'Failed to retrieve partition labels',
|
'Failed to retrieve partition labels',
|
||||||
disk_utils._get_labelled_partition, self.dev,
|
disk_utils._get_labelled_partition, self.dev,
|
||||||
self.config_part_label, self.node_uuid)
|
self.config_part_label, self.node_uuid)
|
||||||
mock_execute.assert_called_once_with('partprobe', self.dev,
|
mock_execute.assert_called_once_with(
|
||||||
run_as_root=True)
|
'partprobe', self.dev, run_as_root=True, attempts=10)
|
||||||
self.assertEqual(1, mock_log.call_count)
|
self.assertEqual(1, mock_log.call_count)
|
||||||
|
|
||||||
def _test_is_disk_larger_than_max_size(self, mock_execute, blk_out):
|
def _test_is_disk_larger_than_max_size(self, mock_execute, blk_out):
|
||||||
|
|
Loading…
Reference in New Issue