From e94511cd251299cee84b8b67d404972988ae28d3 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Tue, 16 Jun 2020 22:39:01 +0200 Subject: [PATCH] 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". Change-Id: I795ee7ca729646be0411a1232bf218015c65010f Closes-Bug: #1883712 --- neutron/conf/common.py | 10 +++++++++- neutron/notifiers/ironic.py | 3 ++- neutron/notifiers/nova.py | 1 + neutron/tests/unit/notifiers/test_nova.py | 2 ++ ...dd-http_retries-config-option-b81dd29c03ba8c6a.yaml | 6 ++++++ 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/Add-http_retries-config-option-b81dd29c03ba8c6a.yaml diff --git a/neutron/conf/common.py b/neutron/conf/common.py index b09e361583b..f8854296134 100644 --- a/neutron/conf/common.py +++ b/neutron/conf/common.py @@ -137,7 +137,15 @@ core_opts = [ 'this value without modification. For overlay networks ' 'such as VXLAN, neutron automatically subtracts the ' '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 = [ diff --git a/neutron/notifiers/ironic.py b/neutron/notifiers/ironic.py index f09e9398bfd..63b77384034 100644 --- a/neutron/notifiers/ironic.py +++ b/neutron/notifiers/ironic.py @@ -67,7 +67,8 @@ class Notifier(object): IRONIC_SESSION = self._get_session(IRONIC_CONF_SECTION) return connection.Connection( - session=IRONIC_SESSION, oslo_conf=cfg.CONF).baremetal + session=IRONIC_SESSION, oslo_conf=cfg.CONF, + connect_retries=cfg.CONF.http_retries).baremetal def send_events(self, batched_events): try: diff --git a/neutron/notifiers/nova.py b/neutron/notifiers/nova.py index 246cff7b6c1..804fb73964e 100644 --- a/neutron/notifiers/nova.py +++ b/neutron/notifiers/nova.py @@ -75,6 +75,7 @@ class Notifier(object): region_name=cfg.CONF.nova.region_name, endpoint_type=cfg.CONF.nova.endpoint_type, extensions=self.extensions, + connect_retries=cfg.CONF.http_retries, global_request_id=global_id) def _is_compute_port(self, port): diff --git a/neutron/tests/unit/notifiers/test_nova.py b/neutron/tests/unit/notifiers/test_nova.py index 2dae5f88c52..10b2550857d 100644 --- a/neutron/tests/unit/notifiers/test_nova.py +++ b/neutron/tests/unit/notifiers/test_nova.py @@ -334,6 +334,7 @@ class TestNovaNotify(base.BaseTestCase): self.nova_notifier.send_events(response) mock_client.assert_called_once_with( api_versions.APIVersion(nova.NOVA_API_VERSION), + connect_retries=3, session=mock.ANY, region_name=cfg.CONF.nova.region_name, endpoint_type='public', @@ -347,6 +348,7 @@ class TestNovaNotify(base.BaseTestCase): self.nova_notifier.send_events(response) mock_client.assert_called_once_with( api_versions.APIVersion(nova.NOVA_API_VERSION), + connect_retries=3, session=mock.ANY, region_name=cfg.CONF.nova.region_name, endpoint_type='internal', diff --git a/releasenotes/notes/Add-http_retries-config-option-b81dd29c03ba8c6a.yaml b/releasenotes/notes/Add-http_retries-config-option-b81dd29c03ba8c6a.yaml new file mode 100644 index 00000000000..5a2ecc5b174 --- /dev/null +++ b/releasenotes/notes/Add-http_retries-config-option-b81dd29c03ba8c6a.yaml @@ -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.