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

fix: respect GitHub rate limiting #377

Merged
merged 4 commits into from
Oct 31, 2023

Conversation

willmurphyscode
Copy link
Contributor

Previously, the client would repeatedly attempt requests until getting actually rate limited by GitHub.

We saw a failure in the quality gate run for another PR that changed the GitHub provider: https://github.com/anchore/vunnel/actions/runs/6693756704/job/18185629045?pr=376#step:4:1530

GitHub's docs mention that failing to abide by these limits can result in escalated responses: https://docs.github.com/en/rest/guides/best-practices-for-using-the-rest-api?ref=retool-blog.ghost.io&apiVersion=2022-11-28#dealing-with-rate-limits

Previously, the client would repeatedly attempt requests until getting
actually rate limited by GitHub.

Signed-off-by: Will Murphy <[email protected]>
Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode added the run-pr-quality-gate Triggers running of quality gate on PRs label Oct 30, 2023
logger.debug(f"github rate limit has {remaining} requests left {reset_time}")
if remaining < 10:
current_time = int(time.time())
sleep_time = reset_time - current_time
Copy link
Contributor

Choose a reason for hiding this comment

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

we should have a sensible cap here since we're sleeping based on user data (e.g. a min of 1 a max of 1 hour?)

@willmurphyscode willmurphyscode enabled auto-merge (squash) October 31, 2023 12:08
@willmurphyscode willmurphyscode merged commit 349985e into main Oct 31, 2023
5 checks passed
@willmurphyscode willmurphyscode deleted the fix/respect-github-rate-limit-headers branch October 31, 2023 12:09
@willmurphyscode willmurphyscode added bug Something isn't working run-pr-quality-gate Triggers running of quality gate on PRs and removed run-pr-quality-gate Triggers running of quality gate on PRs labels Nov 1, 2023
@willmurphyscode
Copy link
Contributor Author

Sorry for the label spam - I was experimenting with the changelog generator.

@willmurphyscode willmurphyscode removed the run-pr-quality-gate Triggers running of quality gate on PRs label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants