diff --git a/ironic_lib/disk_utils.py b/ironic_lib/disk_utils.py index 94005ea1..36558913 100644 --- a/ironic_lib/disk_utils.py +++ b/ironic_lib/disk_utils.py @@ -55,6 +55,10 @@ opts = [ default=3, help='Maximum attempts to verify an iSCSI connection is ' '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 @@ -627,7 +631,8 @@ def _get_labelled_partition(device_path, label, node_uuid): returns None. """ 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 output, err = utils.execute('lsblk', '-Po', 'name,label', device_path, diff --git a/ironic_lib/tests/test_disk_utils.py b/ironic_lib/tests/test_disk_utils.py index 9134c9e8..33745ff3 100644 --- a/ironic_lib/tests/test_disk_utils.py +++ b/ironic_lib/tests/test_disk_utils.py @@ -828,7 +828,7 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase): self.node_uuid) self.assertEqual(part_result, result) 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, check_exit_code=[0, 1], use_standard_locale=True, run_as_root=True) @@ -843,7 +843,7 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase): self.node_uuid) self.assertIsNone(result) 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, check_exit_code=[0, 1], use_standard_locale=True, run_as_root=True) @@ -861,7 +861,7 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase): disk_utils._get_labelled_partition, self.dev, self.config_part_label, self.node_uuid) 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, check_exit_code=[0, 1], use_standard_locale=True, run_as_root=True) @@ -875,8 +875,8 @@ class WholeDiskPartitionTestCases(base.IronicLibTestCase): 'Failed to retrieve partition labels', disk_utils._get_labelled_partition, self.dev, self.config_part_label, self.node_uuid) - mock_execute.assert_called_once_with('partprobe', self.dev, - run_as_root=True) + mock_execute.assert_called_once_with( + 'partprobe', self.dev, run_as_root=True, attempts=10) self.assertEqual(1, mock_log.call_count) def _test_is_disk_larger_than_max_size(self, mock_execute, blk_out):