From cb5fcafe18c55123f863ede7ac4b0abd55f603ef Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Thu, 9 Nov 2017 03:35:41 -0800 Subject: [PATCH] NSX|V: fix timeout out issues The patch addresses 2 things: 1. The deploymen of edges may take longer that the configured timeout. This opertaion now has its own timeout (hardcoded to 20 minutes). 2. The configured timout is now bumoped to double. We have seen that underload there are opertaions that have taken longer than the defult 2 minutes Change-Id: I3ae519b84be58c0f8044fd283aba45f2ed53e431 --- vmware_nsx/common/config.py | 2 +- .../plugins/nsx_v/vshield/common/VcnsApiClient.py | 6 ++++-- vmware_nsx/plugins/nsx_v/vshield/vcns.py | 13 +++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/vmware_nsx/common/config.py b/vmware_nsx/common/config.py index 0842299155..efe16a6e0b 100644 --- a/vmware_nsx/common/config.py +++ b/vmware_nsx/common/config.py @@ -693,7 +693,7 @@ nsxv_opts = [ "networks, as well as ranges of VLAN tags on each " "available for allocation to networks.")), cfg.IntOpt('nsx_transaction_timeout', - default=120, + default=240, help=_("Timeout interval for NSX backend transactions.")), cfg.BoolOpt('share_edges_between_tenants', default=True, diff --git a/vmware_nsx/plugins/nsx_v/vshield/common/VcnsApiClient.py b/vmware_nsx/plugins/nsx_v/vshield/common/VcnsApiClient.py index 8791f93ed4..65e7689a0d 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/common/VcnsApiClient.py +++ b/vmware_nsx/plugins/nsx_v/vshield/common/VcnsApiClient.py @@ -135,8 +135,10 @@ class VcnsApiHelper(object): return ctx.__dict__.get('request_id') def request(self, method, uri, params=None, headers=None, - encodeparams=True): + encodeparams=True, timeout=None): uri = self.address + uri + if timeout is None: + timeout = self.timeout if headers is None: headers = {} @@ -161,7 +163,7 @@ class VcnsApiHelper(object): verify=self.verify_cert, data=data, headers=headers, - timeout=self.timeout) + timeout=timeout) except requests.exceptions.Timeout: raise exceptions.ResourceTimedOut(uri=uri) diff --git a/vmware_nsx/plugins/nsx_v/vshield/vcns.py b/vmware_nsx/plugins/nsx_v/vshield/vcns.py index 54ebda8153..a1cb36c16c 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/vcns.py +++ b/vmware_nsx/plugins/nsx_v/vshield/vcns.py @@ -88,6 +88,7 @@ NETWORK_TYPES = ['Network', 'VirtualWire', 'DistributedVirtualPortgroup'] ROUTING_CONFIG = "routing/config" BGP_ROUTING_CONFIG = "routing/config/bgp" ELAPSED_TIME_THRESHOLD = 30 +MAX_EDGE_DEPLOY_TIMEOUT = 1200 def retry_upon_exception_exclude_error_codes( @@ -123,8 +124,9 @@ class Vcns(object): @retry_upon_exception(exceptions.ServiceConflict) def _client_request(self, client, method, uri, - params, headers, encodeParams): - return client(method, uri, params, headers, encodeParams) + params, headers, encodeParams, timeout=None): + return client(method, uri, params, headers, encodeParams, + timeout=timeout) def do_request(self, method, uri, params=None, format='json', **kwargs): msg = ("VcnsApiHelper('%(method)s', '%(uri)s', '%(body)s')" % @@ -140,9 +142,11 @@ class Vcns(object): else: _client = self.xmlapi_client.request + timeout = kwargs.get('timeout') ts = time.time() header, content = self._client_request(_client, method, uri, params, - headers, encodeParams) + headers, encodeParams, + timeout=timeout) te = time.time() elapsed_time = te - ts @@ -170,7 +174,8 @@ class Vcns(object): @retry_upon_exception(exceptions.RequestBad) def deploy_edge(self, request): uri = URI_PREFIX - return self.do_request(HTTP_POST, uri, request, decode=False) + return self.do_request(HTTP_POST, uri, request, decode=False, + timeout=MAX_EDGE_DEPLOY_TIMEOUT) def update_edge(self, edge_id, request): uri = "%s/%s" % (URI_PREFIX, edge_id)