Browse Source

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
tags/2.21.0^0
Dmitry Tantsur 2 weeks ago
parent
commit
2c7d1cfea0
2 changed files with 32 additions and 2 deletions
  1. 13
    2
      ironic_lib/disk_utils.py
  2. 19
    0
      ironic_lib/tests/test_disk_utils.py

+ 13
- 2
ironic_lib/disk_utils.py View File

@@ -51,10 +51,19 @@ opts = [
51 51
     cfg.StrOpt('dd_block_size',
52 52
                default='1M',
53 53
                help='Block size to use when writing to the nodes disk.'),
54
+    # TODO(dtantsur): remove in Ussuri, then clean up ironic from it.
54 55
     cfg.IntOpt('iscsi_verify_attempts',
55 56
                default=3,
56 57
                help='Maximum attempts to verify an iSCSI connection is '
57
-                    'active, sleeping 1 second between attempts.'),
58
+                    'active, sleeping 1 second between attempts.',
59
+               deprecated_for_removal=True,
60
+               deprecated_reason='Split into [iscsi]verify_attempts and '
61
+                                 'partition_detection_attempts.'),
62
+    cfg.IntOpt('partition_detection_attempts',
63
+               min=1,
64
+               help='Maximum attempts to detect a newly created partition. '
65
+                    'Defaults to iscsi_verify_attempts, will default to 3 '
66
+                    'when it is removed.'),
58 67
     cfg.IntOpt('partprobe_attempts',
59 68
                default=10,
60 69
                help='Maximum number of attempts to try to read the '
@@ -335,7 +344,9 @@ def make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
335 344
 
336 345
 def is_block_device(dev):
337 346
     """Check whether a device is block or not."""
338
-    attempts = CONF.disk_utils.iscsi_verify_attempts
347
+    attempts = (CONF.disk_utils.iscsi_verify_attempts
348
+                if CONF.disk_utils.partition_detection_attempts is None
349
+                else CONF.disk_utils.partition_detection_attempts)
339 350
     for attempt in range(attempts):
340 351
         try:
341 352
             s = os.stat(dev)

+ 19
- 0
ironic_lib/tests/test_disk_utils.py View File

@@ -999,6 +999,25 @@ class OtherFunctionTestCase(base.IronicLibTestCase):
999 999
                           disk_utils.is_block_device, device)
1000 1000
         mock_os.assert_has_calls([mock.call(device)] * 3)
1001 1001
 
1002
+    @mock.patch.object(os, 'stat', autospec=True)
1003
+    def test_is_block_device_attempts(self, mock_os):
1004
+        CONF.set_override('partition_detection_attempts', 2,
1005
+                          group='disk_utils')
1006
+        device = '/dev/disk/by-path/ip-1.2.3.4:5678-iscsi-iqn.fake-lun-9'
1007
+        mock_os.side_effect = OSError
1008
+        self.assertRaises(exception.InstanceDeployFailure,
1009
+                          disk_utils.is_block_device, device)
1010
+        mock_os.assert_has_calls([mock.call(device)] * 2)
1011
+
1012
+    @mock.patch.object(os, 'stat', autospec=True)
1013
+    def test_is_block_device_deprecated_attempts(self, mock_os):
1014
+        CONF.set_override('iscsi_verify_attempts', 4, group='disk_utils')
1015
+        device = '/dev/disk/by-path/ip-1.2.3.4:5678-iscsi-iqn.fake-lun-9'
1016
+        mock_os.side_effect = OSError
1017
+        self.assertRaises(exception.InstanceDeployFailure,
1018
+                          disk_utils.is_block_device, device)
1019
+        mock_os.assert_has_calls([mock.call(device)] * 4)
1020
+
1002 1021
     @mock.patch.object(imageutils, 'QemuImgInfo', autospec=True)
1003 1022
     @mock.patch.object(os.path, 'exists', return_value=False, autospec=True)
1004 1023
     def test_qemu_img_info_path_doesnt_exist(self, path_exists_mock,

Loading…
Cancel
Save