Skip to content

feat(specs): sandbox snapshot specs#721

Open
ninan-nn wants to merge 1 commit intoalibaba:mainfrom
ninan-nn:feature/snapshot_specs
Open

feat(specs): sandbox snapshot specs#721
ninan-nn wants to merge 1 commit intoalibaba:mainfrom
ninan-nn:feature/snapshot_specs

Conversation

@ninan-nn
Copy link
Copy Markdown
Collaborator

@ninan-nn ninan-nn commented Apr 15, 2026

Summary

  • Add sandbox snapshot APIs to the lifecycle spec:
    • POST /sandboxes/{sandboxId}/snapshots creates a snapshot and returns its snapshot id.
    • GET /snapshots lists snapshots with optional sandboxId filtering and pagination.
    • DELETE /snapshots/{snapshotId} deletes a snapshot.
  • Extend POST /sandboxes so a sandbox can be created either from image or restored from snapshotId.
    • Exactly one of image or snapshotId must be provided.
    • entrypoint is required for image-based creation.
    • entrypoint must be omitted for snapshot-based creation because the snapshot carries the startup process.
  • Update Sandbox response shape so the startup source can be represented by either image or snapshotId.
  • Update English and Chinese specs README endpoint summaries.

Testing

  • Not run (spec/docs contract update only; server and SDK implementations are not included in this PR)
  • Unit tests
  • Integration tests
  • e2e / manual verification

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

Notes:

  • This is intended as an additive wire-contract change. Existing image-based sandbox creation remains supported.
  • Server-side validation should enforce the conditional request rules (image xor snapshotId, and entrypoint only for image-based creation).
  • SDK regeneration/handwritten adapter updates are follow-up work; object-level oneOf is intentionally avoided to keep generated SDK models simple, especially for Kotlin.
  • Expected SDK follow-up: expose snapshot management through SandboxManager, including creating a snapshot from a sandbox, listing snapshots, deleting snapshots, and creating/restoring a sandbox from snapshotId.
  • Expected server follow-up: add persistent snapshot storage, persist snapshot objects, and maintain a snapshotId to snapshot runtime configuration mapping so restore requests can resolve the correct runtime artifact/configuration.

@ninan-nn ninan-nn requested a review from Pangjiping April 15, 2026 07:34
@ninan-nn ninan-nn force-pushed the feature/snapshot_specs branch from 195ef2e to 8ed3a0c Compare April 15, 2026 09:25
@ninan-nn ninan-nn marked this pull request as ready for review April 15, 2026 09:44
@ninan-nn ninan-nn requested review from hittyt and jwx0925 as code owners April 15, 2026 09:44
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ed3a0ccf7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +295 to +297
requireNotNull(this.image) {
"Sandbox image is missing from API response. Snapshot-based sandbox responses are not supported by this SDK yet."
}.toImageSpec(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle snapshot-backed sandboxes in converter

The new lifecycle spec allows Sandbox responses that include snapshotId without image, but toSandboxInfo() now unconditionally throws when image is null. In that case getSandboxInfo fails, and listSandboxes will also fail for the entire page as soon as it encounters one snapshot-restored sandbox, which makes the Kotlin SDK unable to interoperate once snapshot restores are used. The converter should map this new response shape instead of hard-failing on missing image.

Useful? React with 👍 / 👎.

$ref: '#/components/schemas/SnapshotState'
style: form
explode: true
- name: page
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In Kubernetes, pagination is not supported via label selectors. Does this require support from external storage?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

#210 server计划做持久化支持
image

Comment thread specs/README_zh.md
- `GET /sandboxes/{sandboxId}` - 获取完整沙箱详情(包含镜像与 entrypoint)
- `GET /sandboxes/{sandboxId}` - 获取完整沙箱详情(包含启动来源与 entrypoint)
- `DELETE /sandboxes/{sandboxId}` - 删除沙箱
- `POST /sandboxes/{sandboxId}/snapshots` - 从沙箱创建快照
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

POST /sandboxes/{sandboxId}/snapshots - 从沙箱创建快照
POST /sandboxes - 从镜像或快照创建沙箱,设置超时与资源限制
区别是啥?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

第一个是创建快照的接口,第二个是基于快照创建沙箱的接口(其实就是原来创建沙箱的接口,只不过额外支持了基于snapshot来创建出一个新沙箱)

The command to execute as the sandbox's entry process.

Required when `image` is provided. Must be omitted when `snapshotId`
is provided because the restored snapshot carries its startup process.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That is incorrect. A snapshot at the rootfs level is merely an image; it does not contain any process information.

Copy link
Copy Markdown
Collaborator Author

@ninan-nn ninan-nn Apr 15, 2026

Choose a reason for hiding this comment

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

这个可能有点理解偏差,这个image是正常沙箱创建的镜像参数(和本次变更其实没啥关系)。针对snapshot场景,sdk用户只感知到他创建了一个snapshot,获取到了一个snapshotId,然后可以直接基于这个snapshotId创建沙箱(就不用传递原来正常创建时候的image参数了)。至于这个snapshotId对应的runtime config 是啥要渲染怎么样的crd,是在server持久化维护的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants