Deprecate [disk_utils]iscsi_verify_attempts

It is not used in ironic-lib for anything explicitly iscsi-related.
Rename it, keeping the option present since ironic uses it.

Change-Id: I86f52dc7e36a35ebcd44eee4f317fe93b5d67cd6
Depends-On: https://review.opendev.org/679463
This commit is contained in:
Dmitry Tantsur 2019-08-30 16:55:09 +02:00
parent 18f775b7ab
commit 2c7d1cfea0
2 changed files with 32 additions and 2 deletions

View File

@ -51,10 +51,19 @@ opts = [
cfg.StrOpt('dd_block_size',
default='1M',
help='Block size to use when writing to the nodes disk.'),
# TODO(dtantsur): remove in Ussuri, then clean up ironic from it.
cfg.IntOpt('iscsi_verify_attempts',
default=3,
help='Maximum attempts to verify an iSCSI connection is '
'active, sleeping 1 second between attempts.'),
'active, sleeping 1 second between attempts.',
deprecated_for_removal=True,
deprecated_reason='Split into [iscsi]verify_attempts and '
'partition_detection_attempts.'),
cfg.IntOpt('partition_detection_attempts',
min=1,
help='Maximum attempts to detect a newly created partition. '
'Defaults to iscsi_verify_attempts, will default to 3 '
'when it is removed.'),
cfg.IntOpt('partprobe_attempts',
default=10,
help='Maximum number of attempts to try to read the '
@ -335,7 +344,9 @@ def make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
def is_block_device(dev):
"""Check whether a device is block or not."""
attempts = CONF.disk_utils.iscsi_verify_attempts
attempts = (CONF.disk_utils.iscsi_verify_attempts
if CONF.disk_utils.partition_detection_attempts is None
else CONF.disk_utils.partition_detection_attempts)
for attempt in range(attempts):
try:
s = os.stat(dev)

View File

@ -999,6 +999,25 @@ class OtherFunctionTestCase(base.IronicLibTestCase):
disk_utils.is_block_device, device)
mock_os.assert_has_calls([mock.call(device)] * 3)
@mock.patch.object(os, 'stat', autospec=True)
def test_is_block_device_attempts(self, mock_os):
CONF.set_override('partition_detection_attempts', 2,
group='disk_utils')
device = '/dev/disk/by-path/ip-1.2.3.4:5678-iscsi-iqn.fake-lun-9'
mock_os.side_effect = OSError
self.assertRaises(exception.InstanceDeployFailure,
disk_utils.is_block_device, device)
mock_os.assert_has_calls([mock.call(device)] * 2)
@mock.patch.object(os, 'stat', autospec=True)
def test_is_block_device_deprecated_attempts(self, mock_os):
CONF.set_override('iscsi_verify_attempts', 4, group='disk_utils')
device = '/dev/disk/by-path/ip-1.2.3.4:5678-iscsi-iqn.fake-lun-9'
mock_os.side_effect = OSError
self.assertRaises(exception.InstanceDeployFailure,
disk_utils.is_block_device, device)
mock_os.assert_has_calls([mock.call(device)] * 4)
@mock.patch.object(imageutils, 'QemuImgInfo', autospec=True)
@mock.patch.object(os.path, 'exists', return_value=False, autospec=True)
def test_qemu_img_info_path_doesnt_exist(self, path_exists_mock,