NSXV: Handle requests ConnectionError exception
DNS failures cause requests module to raise a ConnectionError exception. We should issue a retry upon this exception as DNS erros within a network are normal. Change-Id: Id543a55fbd7002f839981ba47909546ef229f5f9
This commit is contained in:
parent
3104b16023
commit
9f53623d2f
@ -168,6 +168,9 @@ class VcnsApiHelper(object):
|
||||
except requests.exceptions.Timeout:
|
||||
raise exceptions.ResourceTimedOut(uri=uri)
|
||||
|
||||
except requests.exceptions.ConnectionError:
|
||||
raise exceptions.ResourceConnectionError(uri=uri)
|
||||
|
||||
status = response.status_code
|
||||
|
||||
if 200 <= status < 300:
|
||||
|
@ -80,3 +80,7 @@ class ServiceConflict(VcnsApiException):
|
||||
|
||||
class AlreadyExists(VcnsApiException):
|
||||
message = _("Resource %(resource)s already exists")
|
||||
|
||||
|
||||
class ResourceConnectionError(VcnsApiException):
|
||||
message = _("Resource %(uri)s connection error")
|
||||
|
@ -124,6 +124,7 @@ class Vcns(object):
|
||||
self._normalized_global_objects = None
|
||||
|
||||
@retry_upon_exception(exceptions.ServiceConflict)
|
||||
@retry_upon_exception(exceptions.ResourceConnectionError)
|
||||
def _client_request(self, client, method, uri,
|
||||
params, headers, encodeParams, timeout=None):
|
||||
return client(method, uri, params, headers, encodeParams,
|
||||
|
Loading…
x
Reference in New Issue
Block a user