feat(e2b): add dimension-aware API key quota#565
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #565 +/- ##
==========================================
+ Coverage 79.71% 79.83% +0.12%
==========================================
Files 205 225 +20
Lines 15287 17518 +2231
==========================================
+ Hits 12186 13986 +1800
- Misses 2658 2957 +299
- Partials 443 575 +132
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
806b23a to
11bdec7
Compare
0126ba5 to
f196f94
Compare
1688630 to
859dce8
Compare
Add the final Redis-backed quota architecture for E2B API keys with sandbox-manager-owned admission, accounting, anti-drift reconciliation, breaker handling, and metrics. Wire quota subject resolution through the E2B key stores and update sandbox-manager configuration, manifests, docs, unit tests, and e2e coverage for the final design. Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
… flag and runID mechanism The running flag guarded against concurrent Run calls that never happen (Run is called exactly once). The runID mechanism defended against stale OnStartedLeading callbacks, but it is redundant: K8s LeaderElector passes each OnStartedLeading an iteration-scoped context that is canceled when that iteration's Run returns, and the next iteration cannot start until the current Run returns. Any stale callback therefore sees a canceled context and is already rejected by the ctx.Err() check in startLeading. Removed: - running field and guard logic - runID, nextRunID fields - primaryRunIDContextKey type - runID context value injection in Run - runID extraction and check in startLeading - runID reset in stopLeading and Stop Kept: - Retry loop (LeaderElector.Run returns on leadership loss) - stopped flag (parent ctx is canceled after Stop) - done channel (graceful shutdown wait) - ctx.Err() check in startLeading (guards against Stop race) Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
22076e0 to
a596cfa
Compare
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
The no-redis quota job flakes when 12 code-interpreter pods contend on a single kind worker and readiness exceeds 180s. Use 300s to match other pool waits in the same test file. Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Impact
This lets sandbox-manager reject over-quota API key usage before creating new sandbox resources, while keeping the quota implementation scoped to the E2B API and sandbox-manager layers.
Validation
GOCACHE=/private/tmp/go-build-cache /Users/sophon/Bin/go test ./pkg/cache ./pkg/sandbox-manager ./pkg/sandbox-manager/infra/sandboxcr ./pkg/servers/e2b ./pkg/servers/e2b/keys ./pkg/servers/e2b/models ./pkg/servers/e2b/quota