Skip to content

Add rate limit toggles - #884

Merged
gabriel-samfira merged 2 commits into
cloudbase:mainfrom
gabriel-samfira:add-rate-limit-toggles
Sep 12, 2026
Merged

Add rate limit toggles#884
gabriel-samfira merged 2 commits into
cloudbase:mainfrom
gabriel-samfira:add-rate-limit-toggles

Conversation

@gabriel-samfira

@gabriel-samfira gabriel-samfira commented Sep 12, 2026

Copy link
Copy Markdown
Member

This change enables pausing worker loops based on whether or not we are calling into a forge API that has rate limits enabled. There are 2 thresholds for rate limit decisions:

  • non critical loops
  • critical loops

Non critical loops handle scale up or scale down events, react to new jobs requesting a runner, etc.

Critical loops are loops that clean up runners that are marked for deletion, either because they finished a job or because the user requested the deletion. Essentially, we can reserve API calls for ops that save on cost.

We can reserve a certain percentage of the available rate limit quota for critical ops (up to 50%).

As long as the reserved threshold is not reached, all operations run normally. Once the threshold is reached, non critical ops are paused. Once rate limits reach 0 everything that requires an API call to the forge, stops until rate limits reset.

Rate limit reservations are set on the credential level. To reserve some quota for critical ops and set it to a certain percentage you can use:

garm-cli github credentials update \
    --reserve-usage-percentage 15 \
    --reserve-usage-enabled \
    <credential_id>

Rate limits are implemented by GitHub forges only.

Fixes: #616
Fixes: #480

This change adds 2 new toggles for tare limits in github credentials,
and wires them up in the api, models, cli and webapp.

These will be used to make decisions in the various worker loops that need
to make API calls to GH forges.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
With the 2 new knobs we added that control IF we want to reserve
some of the rate limit quota for cleanup operations (critical from
the perspective of managing IaaS cost) and the percentage of how much
we should allocate for the critical ops, this change now takes advantage
of them.

This change enables pausing worker loops based on whether or not we are
calling into a forge API that has rate limits enabled. There are 2
thresholds for rate limit decisions:

* non critical loops
* critical loops

Non critical loops handle scale up or scale down events, react to new jobs
requesting a runner, etc.

Critical loops are loops that clean up runners that are marked for deletion,
either because they finished a job or because the user requested the deletion.
Essentially, we can reserve API calls for ops that save on cost.

We can reserve a certain percentage of the available rate limit quota
for critical ops (up to 50%).

As long as the reserved threshold is not reached, all operations run normally.
Once the threshold is reached, non critical ops are paused. Once rate limits reach 0
everything that requires an API call to the forge, stops until rate limits reset.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
@gabriel-samfira
gabriel-samfira merged commit 6632b9a into cloudbase:main Sep 12, 2026
5 checks passed
@gabriel-samfira
gabriel-samfira deleted the add-rate-limit-toggles branch September 12, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant