Merge "Set min=0 for block_device_allocate_retries option"

This commit is contained in:
Zuul 2019-03-25 23:24:27 +00:00 committed by Gerrit Code Review
commit 0456b43985
4 changed files with 9 additions and 23 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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)

View File

@ -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.