FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit fe0bb440 authored by Dr Rich Wareham's avatar Dr Rich Wareham
Browse files

gapiutil: retry after all errors

Rather than simply retrying after 503 errors, retry after all error
responses since we have also been seeing some spurious 400 responses
from Google.
parent 289e7f31
No related branches found
No related tags found
1 merge request!9gapiutil: retry after all errors
Pipeline #38296 passed
......@@ -24,13 +24,17 @@ def list_all(list_cb, *, page_size=500, retries=2, retry_delay=5, items_key='ite
try:
list_response = list_cb(pageToken=page_token, maxResults=page_size, **kwargs).execute()
except HttpError as err:
if (err.resp.status == 503 and retries > 0):
if (err.resp.status >= 400 and retries > 0):
retries -= 1
LOG.warn('503: Service unavailable - retrying')
LOG.warn('Error response: %s %s - retrying', err.resp.status, err.resp.reason)
sleep(retry_delay)
continue
if retries == 0:
LOG.error('503: Service unavailable - retry count exceeded')
LOG.error(
'Error response: %s %s - retry count exceeded', err.resp.status,
err.resp.reason
)
LOG.error('Error content: %r', err.content)
raise
resources.extend(list_response.get(items_key, []))
......@@ -153,13 +157,17 @@ def get_all_in_list(directory_service, get_cb, *, item_ids=[], id_key='key', bat
try:
batch.execute()
except HttpError as err:
if (err.resp.status == 503 and retries > 0):
if (err.resp.status >= 400 and retries > 0):
retries -= 1
LOG.warn('503: Service unavailable - retrying')
LOG.warn('Error response: %s %s - retrying', err.resp.status, err.resp.reason)
sleep(retry_delay)
continue
if retries == 0:
LOG.error('503: Service unavailable - retry count exceeded')
LOG.error(
'Error response: %s %s - retry count exceeded', err.resp.status,
err.resp.reason
)
LOG.error('Error content: %r', err.content)
raise
break
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment