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

[JENKINS-63078] Allow ignoring rate limits #313

Merged
merged 7 commits into from
Aug 19, 2020

Conversation

sirstrahd
Copy link
Contributor

@sirstrahd sirstrahd commented Jul 15, 2020

Description

This adds ApiRateLimitChecker.NoThrottle, which avoids checking the GitHub rate limits. This is useful for GitHub Enterprise installations. See JENKINS-63078 for further information.

When this change is included, a new strategy will appear on the Github API usage rate limiting strategy selector, called NoThrottle, with the description Ignore rate limit. No requests to the rate_limit endpoint should be performed if it is selected.

Submitter checklist

  • Link to JIRA ticket in description, if appropriate.
  • Change is code complete and matches issue description
  • Automated tests have been added to exercise the changes
  • Reviewer's manual test instructions provided in PR description. See Reviewer's first task below.

Reviewer checklist

  • Run the changes and verify that the change matches the issue description
  • Reviewed the code
  • Verified that the appropriate tests have been written or valid explanation given

Documentation changes

  • Link to jenkins.io PR, or an explanation for why no doc changes are needed

Users/aliases to notify


@Override
public void checkApiRateLimit(@NonNull TaskListener listener, GitHub github) throws IOException, InterruptedException {
// Nothing needed
Copy link
Contributor

Choose a reason for hiding this comment

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

If pointing at https://github.com this setting should pass through to ThrottleOnOver. There is literally never a reason to not check rate limits when interacting with github.com.

Copy link
Contributor

@car-roll car-roll Aug 5, 2020

Choose a reason for hiding this comment

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

Should we block the selection of NoThrottle in the config page if the api uri is github.com?
edit: actually scratch that. For some reason I forgot you can add mulitple servers

// there should be no output
assertEquals(0, countOfOutputLines(m -> m.matches("[sS]leeping")));
// github rate_limit endpoint should not be contacted
githubApi.verify(0, RequestPatternBuilder.newRequestPattern(RequestMethod.GET, urlPathEqualTo("/rate_limit")));
Copy link
Contributor

Choose a reason for hiding this comment

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

Good test.

Copy link
Contributor

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

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

Generally looks good. One change requested.

@sirstrahd
Copy link
Contributor Author

sirstrahd commented Jul 20, 2020

I added the requested behaviour. Added a test for it + took the chance to fix a couple wrong regexs from other test assertions.

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

Successfully merging this pull request may close these issues.

3 participants