Skip to content

[WIP] feat(e2b): add dimension-aware API key quota#565

Open
AiRanthem wants to merge 1 commit into
openkruise:masterfrom
AiRanthem:feature/e2b-api-quota-260622
Open

[WIP] feat(e2b): add dimension-aware API key quota#565
AiRanthem wants to merge 1 commit into
openkruise:masterfrom
AiRanthem:feature/e2b-api-quota-260622

Conversation

@AiRanthem

Copy link
Copy Markdown
Member

Summary

  • add API-key quota modeling for sandbox count plus CPU and memory dimensions
  • enforce quota admission and release in the E2B create/clone flows with Redis-backed live-set tracking
  • add cache health, leader lifecycle, anti-drift reconciliation, storage, config, and documentation updates

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

@kruise-bot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign furykerry for approval by writing /assign @furykerry in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@AiRanthem AiRanthem changed the title [codex] Add dimension-aware API key quota enforcement feat(e2b): add dimension-aware API key quota Jun 23, 2026
@AiRanthem AiRanthem marked this pull request as ready for review June 23, 2026 03:42
@AiRanthem AiRanthem changed the title feat(e2b): add dimension-aware API key quota [WIP] feat(e2b): add dimension-aware API key quota Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.41469% with 415 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.41%. Comparing base (6205b42) to head (11bdec7).

Files with missing lines Patch % Lines
pkg/sandbox-manager/core.go 10.57% 92 Missing and 1 partial ⚠️
pkg/sandbox-manager/quota/antidrift.go 80.56% 43 Missing and 26 partials ⚠️
pkg/sandbox-manager/leader.go 67.45% 46 Missing and 9 partials ⚠️
pkg/cache/cache.go 45.45% 39 Missing and 3 partials ⚠️
pkg/sandbox-manager/quota/redis.go 73.58% 22 Missing and 20 partials ⚠️
pkg/servers/e2b/keys/secret.go 79.78% 12 Missing and 7 partials ⚠️
pkg/servers/e2b/core.go 40.00% 13 Missing and 2 partials ⚠️
pkg/servers/e2b/keys/mysql.go 82.05% 7 Missing and 7 partials ⚠️
pkg/sandbox-manager/quota/spec/model.go 84.14% 7 Missing and 6 partials ⚠️
pkg/sandbox-manager/api.go 80.00% 8 Missing and 4 partials ⚠️
... and 10 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #565      +/-   ##
==========================================
- Coverage   79.84%   79.41%   -0.44%     
==========================================
  Files         202      214      +12     
  Lines       14795    16361    +1566     
==========================================
+ Hits        11813    12993    +1180     
- Misses       2552     2843     +291     
- Partials      430      525      +95     
Flag Coverage Δ
unittests 79.41% <75.41%> (-0.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AiRanthem AiRanthem force-pushed the feature/e2b-api-quota-260622 branch 2 times, most recently from ad19bc4 to 2117df0 Compare June 25, 2026 09:45
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>
@AiRanthem AiRanthem force-pushed the feature/e2b-api-quota-260622 branch from 806b23a to 11bdec7 Compare June 29, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants