Cleanup: validate option at config read level
It's not necessary to make validation for negative retries in code if we have IntOpt min option. Change-Id: I3d42472604d86ba2e5e9b674e8ec2017849aa15a
This commit is contained in:
parent
414df1e56e
commit
883bae38c3
@ -1370,11 +1370,6 @@ class ComputeManager(manager.Manager):
|
||||
LOG.debug("Allocating IP information in the background.",
|
||||
instance=instance)
|
||||
retries = CONF.network_allocate_retries
|
||||
if retries < 0:
|
||||
LOG.warning(_LW("Treating negative config value (%(retries)s) for "
|
||||
"'network_allocate_retries' as 0."),
|
||||
{'retries': retries})
|
||||
retries = 0
|
||||
attempts = retries + 1
|
||||
retry_time = 1
|
||||
bind_host_id = self.driver.network_binding_host_id(context, instance)
|
||||
|
@ -226,7 +226,8 @@ compute_manager_opts = [
|
||||
'host rebooted'),
|
||||
cfg.IntOpt('network_allocate_retries',
|
||||
default=0,
|
||||
help="Number of times to retry network allocation on failures"),
|
||||
help="Number of times to retry network allocation on failures",
|
||||
min=0),
|
||||
cfg.IntOpt('max_concurrent_builds',
|
||||
default=10,
|
||||
help='Maximum number of instance builds to run concurrently'),
|
||||
|
@ -425,33 +425,6 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
dhcp_options=dhcp_options,
|
||||
bind_host_id=instance.get('host'))
|
||||
|
||||
@mock.patch.object(network_api.API, 'allocate_for_instance')
|
||||
def test_allocate_network_neg_conf_value_treated_as_zero(self,
|
||||
mock_allocate):
|
||||
self.flags(network_allocate_retries=-1)
|
||||
|
||||
mock_allocate.side_effect = test.TestingException
|
||||
|
||||
instance = {}
|
||||
is_vpn = 'fake-is-vpn'
|
||||
req_networks = objects.NetworkRequestList(
|
||||
objects=[objects.NetworkRequest(network_id='fake')])
|
||||
macs = 'fake-macs'
|
||||
sec_groups = 'fake-sec-groups'
|
||||
dhcp_options = None
|
||||
|
||||
self.assertRaises(test.TestingException,
|
||||
self.compute._allocate_network_async,
|
||||
self.context, instance, req_networks, macs,
|
||||
sec_groups, is_vpn, dhcp_options)
|
||||
|
||||
mock_allocate.assert_called_once_with(
|
||||
self.context, instance, vpn=is_vpn,
|
||||
requested_networks=req_networks, macs = macs,
|
||||
security_groups=sec_groups,
|
||||
dhcp_options=dhcp_options,
|
||||
bind_host_id=instance.get('host'))
|
||||
|
||||
@mock.patch.object(network_api.API, 'allocate_for_instance')
|
||||
@mock.patch.object(manager.ComputeManager, '_instance_update')
|
||||
@mock.patch.object(time, 'sleep')
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
other:
|
||||
- |
|
||||
network_allocate_retries config param now allows only
|
||||
positive integer values or 0.
|
Loading…
Reference in New Issue
Block a user