feat(e2b): support naming cloned sandbox via metadata extensions#385
feat(e2b): support naming cloned sandbox via metadata extensions#385AiRanthem wants to merge 2 commits into
Conversation
…le cloning sandboxes Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com>
|
[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 #385 +/- ##
==========================================
+ Coverage 75.90% 76.01% +0.10%
==========================================
Files 145 145
Lines 10626 10673 +47
==========================================
+ Hits 8066 8113 +47
Misses 2212 2212
Partials 348 348
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@AiRanthem: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Summary
POST /sandboxeson the clone path:e2b.agents.kruise.io/sandbox-name— setsObjectMeta.Name(mutually exclusive with the next).e2b.agents.kruise.io/sandbox-generate-name— setsObjectMeta.GenerateNameprefix.GenerateName: <checkpointID>-).apivalidation.NameIsDNSLabel); the canonical K8s validator withprefix=truemasks the trailing-forGenerateNameprefixes. Both keys are stripped fromMetadataso they don't leak onto sandbox annotations.sandbox-nameis set) maps to409 Conflictvia the manager's typedErrorConflict.infra.CloneSandboxOptions;newSandboxFromTemplateuses an explicitswitchso the Name/GenerateName precedence is visible at the call site rather than relying on K8s semantics.Public-contract note (beyond the design spec)
The claim path actively rejects these keys with
400 Bad Request(sandbox-name and sandbox-generate-name are only supported for clone). Caller-controlled naming on the claim path is owned bySandboxSetand is out of scope; failing fast is preferable to silently dropping the request.Design
docs/superpowers/specs/2026-05-12-clone-sandbox-name-design.md(in the design branch; not included in this PR).Test plan
go build ./...go vet ./pkg/servers/e2b/... ./pkg/sandbox-manager/...go test ./pkg/servers/e2b/... ./pkg/sandbox-manager/...parseExtensionSandboxNamingtable covers mutual exclusion, empty values, dot rejection, trailing-dash prefix, and key-stripping.ValidateAndInitCloneOptionsrejects both Name and GenerateName set together.newSandboxFromTemplatehonors Name, GenerateName, and falls back to<checkpointID>-.TestCreateSandboxWithClone_Namingend-to-end:Extensions.Name/Extensions.GenerateNameflow through to the resulting SandboxObjectMeta.TestSandboxManager_CloneSandbox"explicit name collision returns conflict" maps toErrorConflict.TestMapCloneSandboxErrorconfirms only manager-wrapped conflict maps to409(rawapierrors.AlreadyExistsis not specially mapped — manager is expected to wrap).TestCreateSandboxWithClaim_NamingExtensionRejectedconfirms claim path returns400.