Raise retryable exception when the returned search data size is too large

Change-Id: Ia980f2f385cf798abed94d8504ba9f013417651b
This commit is contained in:
Shizhao Liu 2023-12-06 21:15:52 +00:00
parent d11fe387c7
commit d979f5d796
4 changed files with 11 additions and 2 deletions

View File

@ -318,6 +318,9 @@ class NsxV3RESTClientTestCase(nsxlib_testcase.NsxClientTestCase):
exc = client.http_error_to_exception(500, 610)
self.assertEqual(exc, nsxlib_exc.APITransactionAborted)
exc = client.http_error_to_exception(500, 60506)
self.assertEqual(exc, nsxlib_exc.NsxSearchDataTooLarge)
exc = client.http_error_to_exception(requests.codes.FORBIDDEN, 505)
self.assertEqual(exc, nsxlib_exc.InvalidLicense)

View File

@ -120,7 +120,8 @@ def http_error_to_exception(status_code, error_code, related_error_codes=None):
{'98': exceptions.CannotConnectToServer,
'99': exceptions.ClientCertificateNotTrusted,
'607': exceptions.APITransactionAborted,
'610': exceptions.APITransactionAborted},
'610': exceptions.APITransactionAborted,
'60506': exceptions.NsxSearchDataTooLarge},
requests.codes.FORBIDDEN:
{'98': exceptions.BadXSRFToken,
'403': exceptions.InvalidCredentials,

View File

@ -37,7 +37,8 @@ class ExceptionConfig(object):
# mark endpoint as DOWN
self.retriables = [v3_exceptions.APITransactionAborted,
v3_exceptions.CannotConnectToServer,
v3_exceptions.ServerBusy]
v3_exceptions.ServerBusy,
v3_exceptions.NsxSearchDataTooLarge]
# When hit during API call, these exceptions will be retried
# after the endpoints are regenerated with up-to-date auth

View File

@ -211,6 +211,10 @@ class NsxSearchPipelineError(NsxLibException):
message = _("Exception while searching during pipeline execution")
class NsxSearchDataTooLarge(NsxLibException):
message = _("Size of data returned by search is too large")
class NsxPendingDelete(NsxLibException):
message = _("An object with the same name is marked for deletion. Either "
"use another path or wait for the purge cycle to permanently "