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

Recheck pr-for-updates workflow #27

Open
glazychev-art opened this issue May 19, 2023 · 2 comments
Open

Recheck pr-for-updates workflow #27

glazychev-art opened this issue May 19, 2023 · 2 comments
Assignees

Comments

@glazychev-art
Copy link
Contributor

Description

Some repositories very often get the error - 403: Forbidden, You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.
https://github.com/networkservicemesh/deployments-k8s/actions/runs/5014568818/jobs/8988977238
https://github.com/networkservicemesh/sdk-sriov/actions/runs/5014807396/jobs/8989537883

Most likely, the github token is used incorrectly

@d-uzlov
Copy link
Contributor

d-uzlov commented May 24, 2023

Github documentation states that there is a global rate limit, which is fairly high:
https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limits-for-requests-from-github-actions

When using GITHUB_TOKEN, the rate limit is 1,000 requests per hour per repository. For requests to resources that belong to an enterprise account on GitHub.com, GitHub Enterprise Cloud's rate limit applies, and the limit is 15,000 requests per hour per repository.

And also there are many unspecified secondary rate limits for certain actions:
https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#secondary-rate-limits

And according to logs, we are hitting some unknown limit for PR creation.

Unable to create pull request: 403: Forbidden, You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.

Here is the github documentation about dealing with secondary rate limits:
https://docs.github.com/en/rest/guides/best-practices-for-integrators?apiVersion=2022-11-28#dealing-with-secondary-rate-limits

I think the reason we hit the limit is that we update our repositories in parallel:

  • Make requests for a single user or client ID serially. Do not make requests for a single user or client ID concurrently.
  • If you're making a large number of POST, PATCH, PUT, or DELETE requests for a single user or client ID, wait at least one second between each request.

The way to handle rate limit errors is just to retry:

  • If the Retry-After response header is present, retry your request after the time specified in the header. The value of the Retry-After header will always be an integer, representing the number of seconds you should wait before making requests again. For example, Retry-After: 30 means you should wait 30 seconds before sending more requests.
  • If the x-ratelimit-remaining header is 0, retry your request after the time specified by the x-ratelimit-reset header. The x-ratelimit-reset header will always be an integer representing the time at which the current rate limit window resets in UTC epoch seconds.
  • Otherwise, wait for an exponentially increasing amount of time between retries, and throw an error after a specific number of retries.

In the repo of the action we use to create PRs there is an issue about retrying PR creation and a branch for testing:

But it doesn't use github guidelines to determine retry timings.

@glazychev-art glazychev-art moved this from Todo to In Progress in Release v1.10.0 May 24, 2023
@glazychev-art glazychev-art moved this from In Progress to Todo in Release v1.10.0 Jun 23, 2023
@glazychev-art glazychev-art moved this from Todo to In Progress in Release v1.10.0 Jul 11, 2023
@glazychev-art glazychev-art moved this from In Progress to Under review in Release v1.10.0 Jul 13, 2023
@glazychev-art glazychev-art moved this from Under review to In Progress in Release v1.10.0 Jul 14, 2023
@NikitaSkrynnik NikitaSkrynnik moved this to Under review in Release v1.11.0 Aug 7, 2023
@NikitaSkrynnik
Copy link
Contributor

NikitaSkrynnik commented Aug 10, 2023

Creating a PR is POST request in Github Rest API. Github Documentation recommends doing this type of requests with one second wait between each request. To make our workflows run sequentially with one second waiting between each two workflows we need:

  1. Create a Large Github Runner
  2. Configure autoscaling to make the runner run only one workflow at a time. Maximum Job Concurrency should be set to 1.
  3. Add one second sleep at the end of pr-for-updates workflow and run it on this runner

Currently there are no functionality in Github to queue workflows using default Github runners for workflows. There are some discussions about this feature but it looks like there are no plans to it yet.

@NikitaSkrynnik NikitaSkrynnik moved this from Under review to Blocked in Release v1.11.0 Aug 10, 2023
@denis-tingaikin denis-tingaikin self-assigned this Sep 28, 2023
@denis-tingaikin denis-tingaikin removed their assignment Oct 6, 2023
@denis-tingaikin denis-tingaikin moved this from Blocked to Moved to next release in Release v1.11.0 Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Moved to next release
Development

No branches or pull requests

4 participants