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

Handle Additional GitHub secondary rate limit failure #68

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .release-notes/68.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Handle Additional GitHub secondary rate limit failure

In our previous version, we added support for retrying when a secondary rate limit failure occurred. However, since that time, we have seen secondary rate limit failures that are not handled by the previous fix. This update adds a retry for the one time we know that the limit can be triggered. If the rate limit is triggered, the bot will wait for 30 seconds before trying again. If it encounters 5 failures, it will give up and quit.
15 changes: 15 additions & 0 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from git.exc import GitCommandError
from github import Github
from github.GithubException import RateLimitExceededException
from github.GithubException import GithubException

CHANGELOG_LABELS = ['changelog - added',
'changelog - changed',
Expand Down Expand Up @@ -67,6 +68,20 @@
else:
print(ERROR + "Search failed again. Giving up." + ENDC)
raise
except GithubException as e:
if "You have exceeded a secondary rate limit" in e.data['message']:
search_failures += 1
if search_failures <= 5:
print(NOTICE
+ "Search failed due to secondary rate limit exceeded. "
+ "Sleeping and trying again."
+ ENDC)
time.sleep(30)
else:
print(ERROR + "Search failed again. Giving up." + ENDC)
raise
else:
raise

repo = github.get_repo(repo_name)
pull_request = repo.get_pull(pr_id)
Expand Down
Loading