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

Add retry when the creation of a Pull Request fails #383

Open
Justinzobel opened this issue Sep 15, 2023 · 0 comments
Open

Add retry when the creation of a Pull Request fails #383

Justinzobel opened this issue Sep 15, 2023 · 0 comments

Comments

@Justinzobel
Copy link

Justinzobel commented Sep 15, 2023

Recently KDE Gear 23.08.1 was released and about 80 of the packages got PRs which are nice and easy to merge.

However, the remaining 50ish got a branch but no Merge Request. I checked the f-e-d-c logs and I can see 71 instances of this error as GitHub is rate-limiting the API.

github.GithubException.GithubException: 403 {'message': 'You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID 9F80:72AD:4EA5F9:A00E26:6502EE6B.', 'documentation_url': '<a href="https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits">https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits</a>'}

I did a quick look and it's using urllib3 which has a retry function (https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html)

It even has a backoff_factor variable which can increase the time between retries and RETRY_AFTER_STATUS_CODES which could be set to 403 which is the error code GitHub is sending back when you hit the rate limit.

From the link to the GitHub REST API docs above it mentions:

You should wait and try your request at a later time. If the retry-after response header is present, you should not retry your request until after that many seconds has elapsed. If the x-ratelimit-remaining header is 0, you should not retry your request until after the time, in UTC epoch seconds, specified by the x-ratelimit-reset header. Otherwise, wait for an exponentially increasing amount of time between retries, and throw an error after a specific number of retries.

This indicates that respect_retry_after_header in urllib3 would also be an effective way of ensuring the next attempt succeeds.

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

No branches or pull requests

1 participant