From 111415d06ef8bda609bfd6a06f472f6c6bb905ef Mon Sep 17 00:00:00 2001 From: Boden R Date: Tue, 2 Feb 2016 05:59:05 -0700 Subject: [PATCH] NSX-v3 HTTP retries conf property This patch adds a new conf property to the nsx.ini under the nsx_v3 group called http_retries. This value is used for the max retries used on HTTP requests. Additionally this patch clarifies the use of http_retries vs retries in the conf properties. A unit test is also included. backport: liberty Change-Id: Ifb0d1aaa6a11163f6520a6472ef743e3eab3ce38 Closes-Bug: #1540885 --- etc/nsx.ini | 5 ++++- vmware_nsx/common/config.py | 6 +++++- vmware_nsx/nsxlib/v3/cluster.py | 2 +- vmware_nsx/tests/unit/nsxlib/v3/test_cluster.py | 9 +++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/etc/nsx.ini b/etc/nsx.ini index 05046f28c2..4911d78587 100644 --- a/etc/nsx.ini +++ b/etc/nsx.ini @@ -341,7 +341,7 @@ # Default Edge Cluster Identifier # default_edge_cluster_uuid = afc40f8a-4967-477e-a17a-9d560d1786c7 -# Maximum number of times to retry API requests +# Maximum number of times to retry API requests upon stale revision errors. # retries = 10 # Specify a CA bundle file to use in verifying the NSX Manager @@ -361,6 +361,9 @@ # The time in seconds before aborting a HTTP read response from a NSX manager. # http_read_timeout = 180 +# Maximum number of times to retry a HTTP connection. +# http_retries = 3 + # Maxiumum number of connection connections to each NSX manager. # concurrent_connections = 10 diff --git a/vmware_nsx/common/config.py b/vmware_nsx/common/config.py index 97fc0d020c..66c0e9b95f 100644 --- a/vmware_nsx/common/config.py +++ b/vmware_nsx/common/config.py @@ -203,7 +203,8 @@ nsx_v3_opts = [ "gateway service plugin.")), cfg.IntOpt('retries', default=10, - help=_('Maximum number of times to retry API request')), + help=_('Maximum number of times to retry API requests upon ' + 'stale revision errors.')), cfg.StrOpt('ca_file', help=_('Specify a CA bundle file to use in verifying the NSX ' 'Manager server certificate. This option is ignored if ' @@ -224,6 +225,9 @@ nsx_v3_opts = [ default=180, help=_('The time in seconds before aborting a HTTP read ' 'response from a NSX manager.')), + cfg.IntOpt('http_retries', + default=3, + help=_('Maximum number of times to retry a HTTP connection.')), cfg.IntOpt('concurrent_connections', default=10, help=_("Maximum concurrent connections to each NSX " "manager.")), diff --git a/vmware_nsx/nsxlib/v3/cluster.py b/vmware_nsx/nsxlib/v3/cluster.py index 9ab709dbf0..6ebf59c238 100644 --- a/vmware_nsx/nsxlib/v3/cluster.py +++ b/vmware_nsx/nsxlib/v3/cluster.py @@ -437,7 +437,7 @@ class NSXClusteredAPI(ClusteredAPI): http_provider=None): self.username = username or cfg.CONF.nsx_v3.nsx_api_user self.password = password or cfg.CONF.nsx_v3.nsx_api_password - self.retries = retries or cfg.CONF.nsx_v3.retries + self.retries = retries or cfg.CONF.nsx_v3.http_retries self.insecure = insecure or cfg.CONF.nsx_v3.insecure self.ca_file = ca_file or cfg.CONF.nsx_v3.ca_file self.conns_per_pool = (concurrent_connections or diff --git a/vmware_nsx/tests/unit/nsxlib/v3/test_cluster.py b/vmware_nsx/tests/unit/nsxlib/v3/test_cluster.py index 1dc150ca3a..1669f000ba 100644 --- a/vmware_nsx/tests/unit/nsxlib/v3/test_cluster.py +++ b/vmware_nsx/tests/unit/nsxlib/v3/test_cluster.py @@ -111,6 +111,15 @@ class NsxV3ClusteredAPITestCase(nsxlib_testcase.NsxClientTestCase): self._assert_providers( api, [(urlparse.urlparse(p).netloc, p) for p in conf_managers]) + def test_http_retries(self): + cfg.CONF.set_override( + 'http_retries', 9, 'nsx_v3') + + api = self.mock_nsx_clustered_api() + with api.endpoints['1.2.3.4'].pool.item() as session: + self.assertEqual( + session.adapters['https://'].max_retries.total, 9) + def test_conns_per_pool(self): cfg.CONF.set_override( 'concurrent_connections', 11, 'nsx_v3')