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

Rate limit error in 1.0.143 #256

Open
ksrisurapaneni opened this issue Jun 28, 2021 · 2 comments
Open

Rate limit error in 1.0.143 #256

ksrisurapaneni opened this issue Jun 28, 2021 · 2 comments

Comments

@ksrisurapaneni
Copy link

ksrisurapaneni commented Jun 28, 2021

Describe the bug
We were using 1.0.132 before, starting using 1.0.143 since Friday. Our process iterates across 5 Git organizations and creates PRs in each if it finds a match. It was running fine in 1.0.132, but fails in 1.0.143 after iterating through 1 or 2 Git orgs with the rate limit exception.

Exception in thread "main" org.kohsuke.github.GHException: Failed to retrieve https://api.github.com/search/code?q=filename%3ADockerfile+user%3Acbsi-cmg+FROM+xyz+container+pipeline+docker.jfrog.io%2Frv-python-3+8-buster
	at org.kohsuke.github.GitHubPageIterator.fetch(GitHubPageIterator.java:155)
	at org.kohsuke.github.GitHubPageIterator.hasNext(GitHubPageIterator.java:91)
	at org.kohsuke.github.PagedSearchIterable$1.hasNext(PagedSearchIterable.java:86)
	at org.kohsuke.github.PagedIterator.fetch(PagedIterator.java:106)
	at org.kohsuke.github.PagedIterator.hasNext(PagedIterator.java:74)
	at org.kohsuke.github.PagedSearchIterable.populate(PagedSearchIterable.java:65)
	at org.kohsuke.github.PagedSearchIterable.getTotalCount(PagedSearchIterable.java:49)
	at com.salesforce.dockerfileimageupdate.utils.DockerfileGitHubUtil.findFilesWithImage(DockerfileGitHubUtil.java:88)
	at com.salesforce.dockerfileimageupdate.utils.DockerfileGitHubUtil.getGHContents(DockerfileGitHubUtil.java:312)
	at com.salesforce.dockerfileimageupdate.subcommands.impl.Parent.execute(Parent.java:61)
	at com.salesforce.dockerfileimageupdate.CommandLine.main(CommandLine.java:52)
Caused by: org.kohsuke.github.HttpException: {
  "documentation_url": "https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#abuse-rate-limits",
  "message": "You have triggered an abuse detection mechanism. Please wait a few minutes before you try again."
}

Can you please look into what changed that we are reaching rate limits so soon?

Thanks,
Keerti

@justinharringa
Copy link
Contributor

Hi @ksrisurapaneni have you had a chance to take a look at https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#abuse-rate-limits (referenced in the error)? Per previous concerns, we're expanding your search now so you may hit many more results.

Would it be possible to include the commands you ran and a rough idea of how many repositories you have in each org?

Hope all is well

@ksrisurapaneni
Copy link
Author

Hi Justin,

One of our largest orgs has around ~5k repos. I was wondering if you could add a sleep and retry condition if this error occurs.

Rough code in Python that I am using in a different use case:

        for i in range(0, int(math.ceil(result.totalCount / 30))):
            try:
                files = result.get_page(i)
                # print(files)
            except StopIteration:
                break
            except RateLimitExceededException:
                search_rate_limit = g.get_rate_limit().search
                logger.warning(f'{search_rate_limit.remaining} API calls remaining')
                reset_timestamp = calendar.timegm(search_rate_limit.reset.timetuple())
                # add 10 seconds to be sure the rate limit has been reset
                sleep_time = reset_timestamp - calendar.timegm(time.gmtime()) + 10
                time.sleep(sleep_time)
                files = result.get_page(i)

Thanks,
Keerti

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

2 participants