Merge "Retry search calls on error"

This commit is contained in:
Zuul 2018-03-19 11:38:27 +00:00 committed by Gerrit Code Review
commit f680a5acd2
3 changed files with 15 additions and 1 deletions

View File

@ -134,8 +134,15 @@ class NsxLibBase(object):
url += "&cursor=%d" % cursor
if page_size:
url += "&page_size=%d" % page_size
# Retry the search on case of error
@utils.retry_upon_exception(exceptions.NsxIndexingInProgress,
max_attempts=self.client.max_attempts)
def do_search(url):
return self.client.url_get(url)
return do_search(url)
def search_all_by_tags(self, tags, resource_type=None):
"""Return all the results searched based on tags."""
results = []

View File

@ -34,6 +34,8 @@ def http_error_to_exception(status_code, error_code):
requests.codes.NOT_FOUND:
{'202': exceptions.BackendResourceNotFound,
'default': exceptions.ResourceNotFound},
requests.codes.BAD_REQUEST:
{'60508': exceptions.NsxIndexingInProgress},
requests.codes.CONFLICT: exceptions.StaleRevision,
requests.codes.PRECONDITION_FAILED: exceptions.StaleRevision,
requests.codes.INTERNAL_SERVER_ERROR:

View File

@ -140,3 +140,8 @@ class SecurityGroupMaximumCapacityReached(ManagerError):
class NsxSearchInvalidQuery(NsxLibException):
message = _("Invalid input for NSX search query. Reason: %(reason)s")
class NsxIndexingInProgress(NsxLibException):
message = _("Bad Request due to indexing is in progress, please retry "
"after sometime")