Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validator: retries on 5xx & 429's #19

Merged
merged 1 commit into from
Mar 19, 2024
Merged

validator: retries on 5xx & 429's #19

merged 1 commit into from
Mar 19, 2024

Conversation

danyalprout
Copy link
Collaborator

Description

Occasionally fetching blobs can fail due to internal server errors, this detects a handful of status codes that we consider retry able for validation.

return retry.Do2(ctx, retryAttempts, retry.Exponential(), func() (int, storage.BlobSidecars, error) {
status, resp, err := endpoint.FetchSidecars(id, format)

if err == nil && status != http.StatusOK && shouldRetry(status) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should you retry on (certain) errors as well? I can see occasional connectivity issues causing errors to be returned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will retry when endpoint.FetchSidecars returns a error (due to a connectivity issue). In that case err != nil, and it'll just fall through to return the original error (which triggers the retry).

Adding this if statement, just ensures that err is set (and will trigger a retry) when the status code is a 5xx or 429.

If you think it's cleaner, we could change this to:

if shouldRetry(status) { return 0, BlobSidecars{}, errors.New(...) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see, no it's fine as is, should have taken a bit more time to understand what was going on.

@danyalprout danyalprout marked this pull request as ready for review March 19, 2024 01:28
@danyalprout danyalprout merged commit d5b160a into master Mar 19, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants