Add config option `http_retries`

This option allows to configure Number of times nova or ironic client
should retry on any failed http call.
Default value for this new option is "3".

Conflicts:
    neutron/notifiers/ironic.py
    neutron/notifiers/nova.py
    neutron/tests/unit/notifiers/test_nova.py

Change-Id: I795ee7ca729646be0411a1232bf218015c65010f
Closes-Bug: #1883712
(cherry picked from commit e94511cd25)
This commit is contained in:
Slawek Kaplonski 2020-06-16 22:39:01 +02:00
parent 8eeb4c074b
commit 290c3a9885
4 changed files with 18 additions and 1 deletions

View File

@ -125,7 +125,15 @@ core_opts = [
'this value without modification. For overlay networks ' 'this value without modification. For overlay networks '
'such as VXLAN, neutron automatically subtracts the ' 'such as VXLAN, neutron automatically subtracts the '
'overlay protocol overhead from this value. Defaults ' 'overlay protocol overhead from this value. Defaults '
'to 1500, the standard value for Ethernet.')) 'to 1500, the standard value for Ethernet.')),
cfg.IntOpt('http_retries', default=3, min=0,
help=_("Number of times client connections (nova, ironic) "
"should be retried on a failed HTTP call. 0 (zero) means"
"connection is attempted only once (not retried). "
"Setting to any positive integer means that on failure "
"the connection is retried that many times. "
"For example, setting to 3 means total attempts to "
"connect will be 4."))
] ]
core_cli_opts = [ core_cli_opts = [

View File

@ -70,6 +70,7 @@ class Notifier(object):
session=session, session=session,
region_name=cfg.CONF.nova.region_name, region_name=cfg.CONF.nova.region_name,
endpoint_type=cfg.CONF.nova.endpoint_type, endpoint_type=cfg.CONF.nova.endpoint_type,
connect_retries=cfg.CONF.http_retries,
extensions=extensions) extensions=extensions)
self.batch_notifier = batch_notifier.BatchNotifier( self.batch_notifier = batch_notifier.BatchNotifier(
cfg.CONF.send_events_interval, self.send_events) cfg.CONF.send_events_interval, self.send_events)

View File

@ -334,6 +334,7 @@ class TestNovaNotify(base.BaseTestCase):
nova.Notifier() nova.Notifier()
mock_client.assert_called_once_with( mock_client.assert_called_once_with(
api_versions.APIVersion(nova.NOVA_API_VERSION), api_versions.APIVersion(nova.NOVA_API_VERSION),
connect_retries=3,
session=mock.ANY, session=mock.ANY,
region_name=cfg.CONF.nova.region_name, region_name=cfg.CONF.nova.region_name,
endpoint_type='public', endpoint_type='public',
@ -344,6 +345,7 @@ class TestNovaNotify(base.BaseTestCase):
nova.Notifier() nova.Notifier()
mock_client.assert_called_once_with( mock_client.assert_called_once_with(
api_versions.APIVersion(nova.NOVA_API_VERSION), api_versions.APIVersion(nova.NOVA_API_VERSION),
connect_retries=3,
session=mock.ANY, session=mock.ANY,
region_name=cfg.CONF.nova.region_name, region_name=cfg.CONF.nova.region_name,
endpoint_type='internal', endpoint_type='internal',

View File

@ -0,0 +1,6 @@
---
features:
- |
A new configuration option ``http_retries`` was added. This option allows
configuring the number of times the nova or ironic client should retry on
a failed HTTP call.