diff --git a/nova/compute/manager.py b/nova/compute/manager.py index ab6b5dcf6d2a..253083ca8427 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1311,13 +1311,8 @@ class ComputeManager(manager.Manager): # TODO(yamahata): eliminate dumb polling start = time.time() retries = CONF.block_device_allocate_retries - if retries < 0: - LOG.warning("Treating negative config value (%(retries)s) for " - "'block_device_retries' as 0.", - {'retries': retries}) - # (1) treat negative config value as 0 - # (2) the configured value is 0, one attempt should be made - # (3) the configured value is > 0, then the total number attempts + # (1) if the configured value is 0, one attempt should be made + # (2) if the configured value is > 0, then the total number attempts # is (retries + 1) attempts = 1 if retries >= 1: diff --git a/nova/conf/compute.py b/nova/conf/compute.py index 159024306bac..a7d68dea7372 100644 --- a/nova/conf/compute.py +++ b/nova/conf/compute.py @@ -639,6 +639,7 @@ Possible values: """), cfg.IntOpt('block_device_allocate_retries', default=60, + min=0, help=""" The number of times to check for a volume to be "available" before attaching it during server create. @@ -662,7 +663,6 @@ Possible values: * 60 (default) * If value is 0, then one attempt is made. -* Any negative value is treated as 0. * For any value > 0, total attempts are (value + 1) Related options: diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index a55a87575a90..c5c9dd4013c9 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -636,21 +636,6 @@ class ComputeVolumeTestCase(BaseTestCase): attempts = c._await_block_device_map_created(self.context, '1') self.assertEqual(attempts, 3) - def test_await_block_device_created_retries_negative(self): - c = self.compute - self.flags(block_device_allocate_retries=-1) - self.flags(block_device_allocate_retries_interval=0.1) - - def volume_get(self, context, vol_id): - return { - 'status': 'available', - 'id': 'blah', - } - - self.stub_out('nova.volume.cinder.API.get', volume_get) - attempts = c._await_block_device_map_created(self.context, '1') - self.assertEqual(1, attempts) - def test_await_block_device_created_retries_zero(self): c = self.compute self.flags(block_device_allocate_retries=0) diff --git a/releasenotes/notes/block_device_allocate_retries-min-0-uprade-dc97b8f0e7716a3b.yaml b/releasenotes/notes/block_device_allocate_retries-min-0-uprade-dc97b8f0e7716a3b.yaml new file mode 100644 index 000000000000..9cf02bb3cf69 --- /dev/null +++ b/releasenotes/notes/block_device_allocate_retries-min-0-uprade-dc97b8f0e7716a3b.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + The ``[DEFAULT]/block_device_allocate_retries`` configuration option now + has a minimum required value of 0. Any previous configuration with a value + less than zero will now result in an error.