Skip to content

feat: Add support to enable backoff when rate limited by the Github API#7192

Closed
andrewhibbert wants to merge 28 commits into
kedacore:mainfrom
andrewhibbert:feat_backoff
Closed

feat: Add support to enable backoff when rate limited by the Github API#7192
andrewhibbert wants to merge 28 commits into
kedacore:mainfrom
andrewhibbert:feat_backoff

Conversation

@andrewhibbert

@andrewhibbert andrewhibbert commented Oct 21, 2025

Copy link
Copy Markdown
Contributor

Adds support to backoff when a rate limit error occurs as per handle rate limit errors appropriately:

  • If the retry-after response header is present, you should not retry your request until after that many seconds has elapsed.
  • If the x-ratelimit-remaining header is 0, you should not make another request until after the time specified by the x-ratelimit-reset header. The x-ratelimit-reset header is in UTC epoch seconds.
  • [N/A]When introducing a new scaler, I agree with the scaling governance policy
  • I have verified that my change is according to the deprecations & breaking changes policy
  • Tests have been added
  • Changelog has been updated and is aligned with our changelog requirements
  • [N/A] A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #6643

Relates to kedacore/keda-docs#1691

andrewhibbert and others added 23 commits March 11, 2025 18:49
@andrewhibbert andrewhibbert requested a review from a team as a code owner October 21, 2025 19:35
@keda-automation keda-automation requested a review from a team October 21, 2025 19:35
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

Comment thread pkg/scalers/github_runner_scaler.go Outdated
if retryAfterStr := header.Get("Retry-After"); retryAfterStr != "" {
retrySeconds, err := strconv.Atoi(retryAfterStr)
if err != nil {
return RateLimit{}, fmt.Errorf("failed to parse Retry-After header. Returned error: %s", err.Error())

@semgrep-app semgrep-app Bot Oct 21, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Semgrep found a possible error wrong wrapped.

🥳 Fixed in commit 9e21288 🥳

Comment thread pkg/scalers/github_runner_scaler.go Outdated
resetStr := header.Get("X-RateLimit-Reset")
reset, err := strconv.ParseInt(resetStr, 10, 64)
if err != nil {
return RateLimit{}, fmt.Errorf("failed to parse X-RateLimit-Reset header. Returned error: %s", err.Error())

@semgrep-app semgrep-app Bot Oct 21, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Semgrep found a possible error wrong wrapped.

🥳 Fixed in commit 9e21288 🥳

Comment thread pkg/scalers/github_runner_scaler.go Outdated
remainingStr := header.Get("X-RateLimit-Remaining")
remaining, err := strconv.Atoi(remainingStr)
if err != nil {
return RateLimit{}, fmt.Errorf("failed to parse X-RateLimit-Remaining header. Returned error: %s", err.Error())

@semgrep-app semgrep-app Bot Oct 21, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Semgrep found a possible error wrong wrapped.

🍰 Fixed in commit 9e21288 🍰

@rickbrouwer rickbrouwer added the merge-conflict This PR has a merge conflict label Nov 5, 2025

@zroubalik zroubalik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please open a docs PR, kedacore/keda-docs#1557 seems to be closed

Comment thread CHANGELOG.md Outdated
- **Elasticsearch Scaler**: Support IgnoreNullValues at Elasticsearch scaler ([#6599](https://github.com/kedacore/keda/pull/6599))
- **GitHub Scaler**: Add support to use ETag for conditional requests against the Github API ([#6503](https://github.com/kedacore/keda/issues/6503))
- **GitHub Scaler**: Filter workflows via query parameter for improved queue count accuracy ([#6519](https://github.com/kedacore/keda/pull/6519))
- **Github Scaler**: Implement backoff when receive rate limit errors ([#6643](https://github.com/kedacore/keda/issues/6643))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not the right location, please add this entry to unreleased section.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have moved this to unreleased section

@snyk-io

snyk-io Bot commented Jan 16, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@keda-automation keda-automation requested a review from a team January 16, 2026 12:44
@rickbrouwer rickbrouwer removed the merge-conflict This PR has a merge conflict label Jan 16, 2026
@andrewhibbert

Copy link
Copy Markdown
Contributor Author

Could you please open a docs PR, kedacore/keda-docs#1557 seems to be closed

Raised kedacore/keda-docs#1691

@JorTurFer JorTurFer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking really nice,m great job! My only question at this point is if calling this backoff still makes sense as it's not a backoff but an intelligent 429 management. And the other question that comes to my mind if this should be optional or built-in directly

@keda-automation keda-automation requested a review from a team January 26, 2026 09:11
@zroubalik zroubalik added the waiting-author-response All PR's or Issues where we are waiting for a response from the author label Jan 28, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale All issues that are marked as stale due to inactivity label Mar 30, 2026
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

This pull request has been automatically closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale All issues that are marked as stale due to inactivity waiting-author-response All PR's or Issues where we are waiting for a response from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement backoff when receive rate limit errors in the Github scaler

4 participants