feat(server): expose snapshot restore image reference (imageUri) in the Snapshot API#995
feat(server): expose snapshot restore image reference (imageUri) in the Snapshot API#995ferponse wants to merge 2 commits into
Conversation
…he Snapshot API
The Snapshot REST response (POST /sandboxes/{id}/snapshots, GET /snapshots/{id},
GET /snapshots) did not include the resulting OCI image reference, although the
server already stores it in SnapshotRecord.restore_config.image. Expose it as
'imageUri' (populated once Ready) so a snapshot can be restored on a different
server/runtime via the create-from-image path -- snapshotId restore is limited
to the originating server's snapshot store. See opensandbox-group#994.
Co-authored-by: Atenea Agent <srv_atenea_gitlab@ofidona.net>
|
Changed directories: server. 📋 Recommended labels (based on changed files):
Other available labels:
💡 Tip: Use cc @ferponse |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6955ecbbef
ℹ️ 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".
| image_uri: Optional[str] = Field( | ||
| None, | ||
| alias="imageUri", | ||
| description=( |
There was a problem hiding this comment.
Add imageUri to the public Snapshot contract
This exposes imageUri in the server response model, but the lifecycle API spec remains the public source of truth and its Snapshot schema still omits this property while declaring additionalProperties: false (specs/sandbox-lifecycle.yml lines 890-920). Clients and SDKs generated from that spec will not discover or model the new restore image field, so the cross-server restore workflow this change enables is still unavailable through the documented contract; please update the spec and regenerate affected outputs.
Useful? React with 👍 / 👎.
Service-level: get_snapshot exposes restore_config.image as image_uri once
Ready; absent while Creating. Route-level: GET /v1/snapshots/{id} serializes
the camelCase imageUri alias and omits it when None.
Co-authored-by: Atenea Agent <srv_atenea_gitlab@ofidona.net>
…gate to clients Addresses the Codex review on opensandbox-group#995: the lifecycle spec is the public source of truth and declared additionalProperties:false without imageUri, so generated SDKs would not model the new restore-image field. - specs/sandbox-lifecycle.yml: add optional imageUri to the Snapshot schema. - python SDK: regenerate the lifecycle client (snapshot.py) from the spec. - go SDK: add ImageURI to the hand-written SnapshotInfo (json imageUri). kotlin and csharp regenerate their lifecycle clients from the spec at build time; the javascript committed openapi-typescript client needs 'npm run generate' (toolchains not available in this environment). Co-authored-by: Atenea Agent <srv_atenea_gitlab@ofidona.net>
0de66a7 to
a8f173b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0de66a79a1
ℹ️ 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".
| status: SnapshotStatus | ||
| created_at: datetime.datetime | ||
| name: str | Unset = UNSET | ||
| image_uri: str | Unset = UNSET |
There was a problem hiding this comment.
Forward imageUri into public SDK models
When SDK users call get_snapshot/create_snapshot for a Ready snapshot, this generated wire field is still dropped before it reaches the public SDK objects: the Python converter builds SnapshotInfo without image_uri (sdks/sandbox/python/src/opensandbox/adapters/converter/sandbox_model_converter.py lines 502-513) and the public Python/Kotlin/C# SnapshotInfo models do not expose the property. That leaves most documented SDK clients unable to obtain the restore image this API field is meant to provide, even though the server and spec now return it; please propagate it through the handwritten SDK models/converters as well.
Useful? React with 👍 / 👎.
What
Expose the snapshot's restore image reference as
imageUriin theSnapshotAPI model. It is populated once the snapshot reachesReady, sourced from the value the server already stores inSnapshotRecord.restore_config.image.Implements #994.
Why
Today the
Snapshotresponses (POST /sandboxes/{id}/snapshots,GET /snapshots/{id},GET /snapshots) do not return the resulting OCI image reference. The server computes and stores it, but only uses it internally to resolve same-serversnapshotIdrestores. Since the snapshot store is per-server, restoring a snapshot on a different server or runtime requires the raw image ref via the create-from-image path — which clients currently cannot obtain from the API.This blocks cross-server / cross-runtime restore (e.g. moving a sandbox between a local Docker-runtime server and a Kubernetes/
batchsandboxserver through a shared registry).Change
server/opensandbox_server/api/schema.py: add optionalimage_uri(aliasimageUri) toSnapshot.server/opensandbox_server/services/snapshot_service.py: populate it in_to_snapshot_responsefromrecord.restore_config.image.Additive and backward-compatible: the field is
Optionaland omitted while the snapshot is notReady(the endpoints already useresponse_model_exclude_none=True).Verification
Built the server image from this branch and ran it with
runtime=docker:GET /snapshots/{id}whileCreating→ noimageUri(omitted).Ready→"imageUri": "opensandbox-snapshots:<id>", matching the committed docker image.The same
_to_snapshot_responsemapping serves the Kubernetes runtime, whererestore_config.imageis the registry ref pushed by the commit Job (SandboxSnapshot.status.containers[].imageUri).