Retry on internal server error 98

Change-Id: I4dbc7d1f34b7d7672b8fca8e8667e2d266faca14
This commit is contained in:
asarfaty 2020-01-06 09:54:24 +02:00 committed by Adit Sarfaty
parent 07211d7173
commit 01aa48a5d3
2 changed files with 10 additions and 3 deletions

View File

@ -46,7 +46,8 @@ def http_error_to_exception(status_code, error_code):
requests.codes.CONFLICT: exceptions.StaleRevision, requests.codes.CONFLICT: exceptions.StaleRevision,
requests.codes.PRECONDITION_FAILED: exceptions.StaleRevision, requests.codes.PRECONDITION_FAILED: exceptions.StaleRevision,
requests.codes.INTERNAL_SERVER_ERROR: requests.codes.INTERNAL_SERVER_ERROR:
{'99': exceptions.ClientCertificateNotTrusted, {'98': exceptions.CannotConnectToServer,
'99': exceptions.ClientCertificateNotTrusted,
'607': exceptions.APITransactionAborted}, '607': exceptions.APITransactionAborted},
requests.codes.FORBIDDEN: requests.codes.FORBIDDEN:
{'98': exceptions.BadXSRFToken}, {'98': exceptions.BadXSRFToken},
@ -323,7 +324,9 @@ class NSX3Client(JSONRESTClient):
def _rest_call(self, url, **kwargs): def _rest_call(self, url, **kwargs):
if kwargs.get('with_retries', True): if kwargs.get('with_retries', True):
# Retry on "607: Persistence layer is currently reconfiguring" # Retry on "607: Persistence layer is currently reconfiguring"
retry_codes = [exceptions.APITransactionAborted] # and on "98: Cannot connect to server"
retry_codes = [exceptions.APITransactionAborted,
exceptions.CannotConnectToServer]
if self.rate_limit_retry: if self.rate_limit_retry:
# If too many requests are handled by the nsx at the same time, # If too many requests are handled by the nsx at the same time,
# error "429: Too Many Requests" or "503: Server Unavailable" # error "429: Too Many Requests" or "503: Server Unavailable"

View File

@ -220,10 +220,14 @@ class NsxOverlapVlan(NsxLibInvalidInput):
"physical devices resulting in a conflict") "physical devices resulting in a conflict")
class APITransactionAborted(ServerBusy): class APITransactionAborted(ManagerError):
message = _("API transaction aborted as MP cluster is reconfiguring") message = _("API transaction aborted as MP cluster is reconfiguring")
class CannotConnectToServer(ManagerError):
message = _("Cannot connect to server")
class ResourceInUse(ManagerError): class ResourceInUse(ManagerError):
message = _("The object cannot be deleted as either it has children or it " message = _("The object cannot be deleted as either it has children or it "
"is being referenced by other objects") "is being referenced by other objects")