DXCDT-541: Persistent rate limit handling #839
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔧 Changes
The Auth0 CLI already has some solid retry logic when making requests to the Management API. By default, it will retry up to 5 times for 429s and 500s. This is fine for most cases, however with the addition of the
tf generate
command, many request could be made in a short period of time, occasionally making the retry logic insufficient.This PR adds a bespoke handler that enables intelligent retries depending on HTTP status code. 429s are retried until they succeed while other error codes like 500s are retried a finite amount of times. This is the exact same logic that is used for the Terraform Provider (related).
Solves #420 by retrying on 502s.
📚 References
🔬 Testing
Unit test from #788 added. Manual verification with highly repetitive API requests that trigger flood of 429s.
📝 Checklist