Skip to content

docs: propose short and stable Sandbox IDs#635

Merged
AiRanthem merged 1 commit into
openkruise:masterfrom
AiRanthem:feature/short-sandbox-id-260709
Jul 14, 2026
Merged

docs: propose short and stable Sandbox IDs#635
AiRanthem merged 1 commit into
openkruise:masterfrom
AiRanthem:feature/short-sandbox-id-260709

Conversation

@AiRanthem

Copy link
Copy Markdown
Member

What changed

  • Add the detailed design specification for short, stable Sandbox IDs derived from the full Kubernetes Sandbox UID.
  • Add a reviewer-oriented proposal covering user-visible behavior, persisted label ownership, package boundaries, cache lookup, shared manager/gateway routing, diagnostics, rollout, rollback, observability, and tests.
  • Define the mixed-version Route state machine, conditional delete fencing, collision quarantine, and authoritative sweep needed for a one-ID-per-Sandbox migration.

Why

The current <namespace>--<name> Sandbox ID is embedded in E2B-compatible dynamic hostnames. Long namespace and Sandbox names can make the resulting DNS name too long to access, even when the Sandbox itself is healthy.

The proposal uses a 26-character lowercase Base32 representation of the complete 128-bit Sandbox UID and persists the selected value in agents.kruise.io/sandbox-id. Unlabeled Sandboxes retain the legacy ID, and the assignment flag remains disabled by default for rollout safety.

Impact

This PR changes documentation only; it does not change runtime behavior. It establishes the technical-review contract for a later implementation plan, including compatibility and activation gates.

Validation

  • git diff --check upstream/master...HEAD
  • Verified that the branch differs from upstream only by the design spec and proposal.
  • Cross-checked the proposal against the design acceptance criteria and migration boundaries.
  • Go tests were not run because this PR contains documentation only.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.05%. Comparing base (5c9549f) to head (6d773b0).
⚠️ Report is 23 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #635      +/-   ##
==========================================
+ Coverage   80.00%   80.05%   +0.05%     
==========================================
  Files         225      229       +4     
  Lines       17645    17861     +216     
==========================================
+ Hits        14117    14299     +182     
- Misses       2953     2976      +23     
- Partials      575      586      +11     
Flag Coverage Δ
unittests 80.05% <ø> (+0.05%) ⬆️

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.

check.

Manager route watch registration and periodic reconciliation move out of `sandboxcr.Infra` into
the sandbox-manager composition root. Gateway keeps its controller adapter. Both use the same

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.

The gateway controller constructs the sandbox ID directly from the reconcile request's namespace/name without reading the Sandbox's label. When short IDs are enabled, this code would still produce the legacy -- key, causing a mismatch with the short ID stored in the registry by other components, please be more specific about the change of sandbox-gateway

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Expanded the gateway adapter design in a4070ab. For a present Sandbox, the reconciler projects a full Route through the injected label-aware resolver and offers it to the shared Store without deriving the registry key from the reconcile request. For NotFound or deleting objects, it deletes authoritatively by ObjectKey; <namespace>--<name> is only the mixed-version fallback when no full ObjectKey record exists. The gateway sweep uses the same watch visibility and inclusion predicate.


#### Authoritative Sweep

Both components run the shared Sweeper once after cache synchronization and then every five minutes

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.

is it possible to only check the specified routes in doubt, the one "Different UID with equal or unorderable RV". GET is much cheaper than LIST operation

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The original List was intended as a low-frequency background cleanup: once after cache synchronization and then every five minutes with jitter, outside the request and normal reconcile paths. However, at the expected scale of hundreds of thousands of Sandboxes, a full direct List per manager/gateway replica is still too expensive. Revised in afba1b1 to remove the periodic full List. When the Store detects a known ambiguity, it quarantines the ID and returns the affected ObjectKeys and mutation generations. The event adapter enqueues them into a deduplicated, rate-limited repair queue and completes event processing immediately. A worker performs direct Gets only for those keys and applies the authoritative result only if the affected-record generation still matches; transient errors retry with backoff. Normal population and missed-event recovery continue to rely on informer synchronization and List/Watch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Design changed

@furykerry

Copy link
Copy Markdown
Member

/lgtm

@kruise-bot

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@zmberg

zmberg commented Jul 14, 2026

Copy link
Copy Markdown
Member

/approve

Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
@AiRanthem
AiRanthem force-pushed the feature/short-sandbox-id-260709 branch from 1c10a7b to 6d773b0 Compare July 14, 2026 11:19
@kruise-bot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zmberg

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

The pull request process is described 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 marked this pull request as ready for review July 14, 2026 11:19
@kruise-bot
kruise-bot requested a review from furykerry July 14, 2026 11:20
@AiRanthem
AiRanthem merged commit c1c04fb into openkruise:master Jul 14, 2026
16 of 18 checks passed
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.

4 participants