feat(allocation_policies): add org allowlist to bypass all rate limits#8151
Open
phacops wants to merge 4 commits into
Open
feat(allocation_policies): add org allowlist to bypass all rate limits#8151phacops wants to merge 4 commits into
phacops wants to merge 4 commits into
Conversation
Introduce a single global runtime config, `organization_rate_limit_bypass_allowlist`, holding a comma-separated list of organization ids. Orgs in this list skip ALL allocation policies (rate limits) entirely, the same way an inactive policy is skipped. The check is added to the base `AllocationPolicy` in both `get_quota_allowance` and `update_quota_balance`, so it applies uniformly to every policy (concurrent rate limit, bytes-scanned, referrer guard rail, etc.) and covers both the legacy and RPC query pipelines. Adding it to `update_quota_balance` too prevents bookkeeping corruption (e.g. the concurrent-limit policy removing a query it never recorded). The allowlist is a global config (visible in the runtime config admin UI) rather than a per-policy Capacity Management config so a single edit exempts an org from every rate limit at once. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PjLqLCQ38BrNp1TKckiNex
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c634d7. Configure here.
Runtime config coerces a lone value to its typed form, so a single org id of 0 was stored as the integer 0 and the previous falsy check treated it as an unset allowlist. Check `is None` instead so 0 is honored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PjLqLCQ38BrNp1TKckiNex
update_quota_balance can be called with a None tenant_ids (exercised by test_passes_through_on_error), which broke when the new bypass check called .get() on it. Return early when tenant_ids is falsy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PjLqLCQ38BrNp1TKckiNex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds a way to maintain an allowlist of organizations that bypass all allocation policies (rate limits) at once.
What
organization_rate_limit_bypass_allowlist— a comma-separated list of organization ids (e.g."1,42,1337").max_threads, unlimited bytes).How
AllocationPolicy(snuba/query/allocation_policies/__init__.py) via a newis_rate_limit_bypassed(tenant_ids)helper, gated ontenant_ids["organization_id"].get_quota_allowance— alongside the existingis_activecheck, returning a passthrough allowance.update_quota_balance— alongside the same check, so bypassed orgs don't corrupt policy bookkeeping (e.g. the concurrent-limit policy removing a query it never recorded).get_quota_allowance, this covers every policy (concurrent rate limit, bytes-scanned, referrer guard rail, cross-org, …) across both paths with one edit.Why a global config
It's a single global runtime config (visible in the runtime config admin UI) rather than a per-policy Capacity Management config, so one edit exempts an org from all rate limits at once instead of having to set an override on each policy individually. Operators maintain the list from the existing runtime config admin UI.
Notes / scope
RoutingStrategySelector) is a separate path and is intentionally not changed here — this PR is about bypassing rate limits, not forcing a routing tier.Tests
Added to
tests/query/allocation_policies/test_allocation_policy_base.py:update_quota_balanceis skipped for a bypassed org (proven via a policy that raises in its private methods).organization_idare never bypassed.Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
🤖 Generated with Claude Code
Generated by Claude Code