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

PR Pagination Fails #1780

Closed
dermidgen opened this issue Dec 14, 2022 · 4 comments
Closed

PR Pagination Fails #1780

dermidgen opened this issue Dec 14, 2022 · 4 comments
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@dermidgen
Copy link

Related to:

TLDR

  • Release Please PR iterator is not graceful when hitting errors & API rate limits
  • Release Please PR iteration exhausts API rate limits very quickly for non enterprise accounts

Here's the details of this bug:

  • PR pagination fails for larger repos with >= 200 closed/merged pull requests
    • It looks for PRs against the target branch so after enough releases you hit this on even a small repo
    • It iterates through 200 PRs every single time
  • Paging PRs and some resources from the GH APIs may hit occasional 502's reported as "Server Error"
  • RP is using the REST pagination tool from octokit for finding merged PRs
  • The REST iterator does not use the throttle/retry plugin in octokit (the GraphQL iterator does)
  • When searching for merged PRs you get unhandled 502's and die
  • When searching for 200 PRs, iterating many commits between releases, etc you hit actual API rate limits pretty quickly
  • The longer you wait between releases, the more commits you iterate, the higher the likelihood of failure once you get to PRs

Attempts to mitigate

  • Dedicated user & token to isolate API requests (nope)
    • Doesn't help - you hit 502's anyways even if you're not getting "rate limited"
    • Still blasts through soft rate limits pretty quickly, which are not handled gracefully
  • Dedicated release branch (nope)
    • Once you merge enough release PRs, you're in the same spot again
    • Sucks if you're trunk-based
  • Switch to GraphQL (BETTER!)
    • Modified local sources for Release Please in node_modules to switch to the GraphQL strategy; HELPED!
    • It's graceful! It can handle the 502's AND API soft rate limiting
    • It still runs so many requests you get rate limited pretty quickly

Deeper detail

Screenshot 2022-12-14 at 3 18 41 PM

Screenshot 2022-12-14 at 3 21 43 PM

Switch to using GraphQL and you get:
Screenshot 2022-12-14 at 3 13 17 PM

I locally modified https://github.com/googleapis/release-please/blob/main/src/github.ts#L619 to use pullRequestIteratorWithFiles instead of pullRequestIteratorWithoutFiles. Since pullRequestIteratorWithFiles uses the GraphQL API through octokit - you get fault tolerance and retries. Technically, the REST iterator through octokit should do the same thing; but it doesn't.

Further, octokit violates Github's Docs by sending the application/vnd.github.v3+json accept header - which should be application/vnd.github+json.

Solution Path

Switch to GraphQL iterator for PRs

  • Solves failures on soft API limits & 502 "Server Error"

I will likely submit a PR to switch away from the REST iterator for PRs. This is a vastly improved experience, fault tolerant and more verbose. This does NOT resolve the overall issue of Release Please exhausting API request limits through aggressively paging through 200 hundred PRs at multiple stages. It would be nice if that 200 PR lookup limit was configurable.

@dermidgen dermidgen added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 14, 2022
@dermidgen
Copy link
Author

@chingor13 wanted to check and see if you've had a chance to review this issue. Currently, we're working off of forks, which sucks. Do you want a PR with the change I described? It's rather fugly, but it's at least making this a usable tool on our monorepo.

@chingor13
Copy link
Contributor

Sorry for the delay in responding. We would be willing to possibly switch to graphql queries if it's faster or more consistent. We have noticed though that graphql can also be flaky and is not really transparent about what fails.

@dermidgen
Copy link
Author

Gosh, bummer. At least the GraphQL SDK has retries & back-offs. It's far more gracious. We haven't seen any bad behavior from GraphQL so far.

@chingor13 chingor13 added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 18, 2023
@Djiit
Copy link

Djiit commented Feb 8, 2024

Hey team, how can we help prioritize or implement this ? Thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants