Repository navigation
Enhance setup-python Action in GitHub Enterprise Server with Raw API Fallback Mechanism #756
Description
Description:
In the context of GitHub Enterprise Server (GHES), it is typical for runners to share the same IP address due to Network Address Translation (NAT). This configuration results in the quick exhaustion of the unauthenticated rate limit (60 requests per hour per IP address) when accessing the versions-manifest.json file, leading to failures in the setup-python action. The current workaround is to incorporate a "github.com" token into the setup-python action. Although this solution is functional, it necessitates the creation of an additional github.com token (and technical user) for each repository/team, which is not optimal. Moreover, Pull Requests from forks are not supported due to their lack of access to the secret.
A potential improvement could be leveraging the raw API to retrieve the version-manifest, as it does not impose a rate limit and hence facilitates unrestricted consumption without the need for a token.
Justification:
Our GitHub Enterprise Server has frequently encountered rate limit issues, and the manual token addition method does not scale well. Utilizing the raw API as a fallback could provide an automatic workaround for this issue. If this approach fails, users can still resort to adding a token.
Are you willing to submit a PR?
I have created a fork to verify that the raw API isn't affected by the rate limit and can be used as a fallback solution. (https://github.com/actions/setup-python/compare/main...Shegox:setup-python:raw-access?expand=1)
The log extract from the workaround is as follows:
Version 3.10 was not found in the local cache
##[debug]Getting manifest from actions/python-versions@main
##[debug]{"name":"HttpClientError","statusCode":403,"result":{"message":"API rate limit exceeded for xx.xx.xx.xx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}}
##[debug]Fetching via the API failed. Fetching using raw URL.
##[debug]check 3.13.0-alpha.1 satisfies 3.10
##[debug]check 3.12.0 satisfies 3.10
##[debug]check 3.12.0-rc.3 satisfies 3.10
##[debug]check 3.12.0-rc.2 satisfies 3.10
##[debug]check 3.12.0-rc.1 satisfies 3.10
I am prepared to submit a PR incorporating the proposed changes.
Before proposing this PR I wanted to check if that would be accepted or if there are other ideas to overcome this?
Related Issues
- Unable to use built-in GitHub Token for avoiding rate limit issues on GHES #683
- Rate limit token does not work on GHE #638
- Getting Bad Credentials error when passing token input in GHE #666
- Add support for adding a token on GHES to prevent rate limiting #316
- Add support for locally hosted GHES instances to reduce rate limiting #720
Activity
dmitry-shibanov commentedon Oct 31, 2023
Hello @Shegox. Thank you for your report. We'll take a look on it.
Shegox commentedon Nov 15, 2023
I had some more time today and created #766 as an implementation of this idea, would be happy about feedback and maybe getting this merged :)
v-priya-kinthali commentedon Feb 13, 2024
Hello @Shegox 👋,
Thank you for your contribution.
We have incorporated your proposed changes into the setup-actions-demo/setup-python@main branch. Could you kindly verify if the issue related to the rate limit has been resolved and confirm that no other new issues have emerged!
If there are no new issues, we will proceed with merging the original PR and releasing it.
Shegox commentedon Feb 13, 2024
@priya-kinthali just checked it again and it works with the
setup-actions-demofork as well. I copied the action over to my local Enterprise Server and run it there. Here the log extract:I checked as well that the current PR (#766) doesn't overwrite any changes to the transpiled dist. So from my side it is good to be merged. Looking forward to seeing it merged!
Shegox commentedon Mar 25, 2024
@priya-kinthali did you have time to check on this issue and the PR (#766)?
I merged origin/main again to ensure that the PR is up to date
v-priya-kinthali commentedon Mar 26, 2024
Hello @Shegox 👋,
We have completed the review of your changes in PR #766 and are excited to announce that they will be included in our upcoming release. Your contribution significantly improves our project and we truly appreciate your effort. We look forward to more collaborations in the future.
Thank you once again for your valuable contribution:)