Skip to content

gvisor: resume Data snapshots on the golden snapshot (#451, phase 2) - #790

Closed
Dmitry Berkovich (dberkov) wants to merge 1 commit into
agent-substrate:mainfrom
dberkov:resumeFromDataGVisor
Closed

Dmitry Berkovich (dberkov) wants to merge 1 commit into
agent-substrate:mainfrom
dberkov:resumeFromDataGVisor

Conversation

@dberkov

Copy link
Copy Markdown
Collaborator

Phase 2 of #451: extends the onResume.fromData: Golden data resume (micro-VM support merged in #683) to the gVisor runtime.

What

A gVisor actor with onCommit: Data + onResume: { fromData: Golden } now resumes as the template's golden snapshot (guest memory + rootfs) with the actor's durable-dir data restored over it — instead of cold-booting. Works for both durable (commit) snapshots and local pause checkpoints.

How

Built on runsc's new split checkpoints:

  • runsc checkpoint -split-fscheckpoint writes the memory snapshot at the checkpoint's top level and the durable-dir fs image under fs/; runsc restore -split-fsrestore reads both halves from -image-path.
  • ateom-gvisor: lists snapshot files recursively so the fs/ half ships with the manifest; passes --fs-restore-image-path <dir>/fs at create/restore time when the fs/ folder exists; DATA_ON_GOLDEN restores through the Full path.
  • atelet: stages a gVisor DATA_ON_GOLDEN restore as one folder shaped like a Full split snapshot whose fs half is the actor's — the golden's files minus its fs/ contents at the top level, and the actor's flat fscheckpoint image set re-rooted into fs/, overriding it wholesale. Micro-VM keeps its flat shadow-merge. Staging is subdir-aware, with parent directories created once per distinct dir (ensureParentDirs) on the download, local-copy, and pause-move paths.
  • Version guard: gVisor checkpoint images are runsc-version-coupled (unlike the micro-VM durable tar), so a combine requires the actor's and golden's pinned runsc sha256 to match — FailedPrecondition otherwise.
  • CRD: the CEL gate restricting onResume.fromData: Golden to sandboxClass: microvm is lifted.

Testing

  • Unit: atelet staging tests for the gVisor fs-override layout (golden fs/ excluded, actor image re-rooted, subdir created on demand) and the micro-VM merged layout; filesOutsideDir filter; recursive listSnapshotFiles.
  • e2e (suites/demo): the two OnGolden lifecycle cases (commit path and pause path) are no longer micro-VM-gated and run in the gVisor lane; expected counters are unchanged.
  • Manually verified on GKE: gVisor actor created from golden, called, suspended (Data), resumed with the golden's memory and the actor's file counter continuing.

Draft blockers

  • sandboxconfig-gvisor.yaml temporarily pins a split-checkpoint runsc build from a private test bucket (gs://snapshot-substrate-test-…/gvisor-split-checkpoint/runsc); needs a public/released runsc with -split-fscheckpoint/-split-fsrestore before this can merge (the gVisor e2e lane also depends on it).
  • runsc debug logging is enabled on create/start/checkpoint/restore for bring-up; decide whether to keep it before merge.

🤖 Generated with Claude Code

…ta, agent-substrate#451 phase 2)

Extends the OnGolden data resume to the gVisor runtime, built on runsc's
new split checkpoints: 'runsc checkpoint -split-fscheckpoint' writes the
memory snapshot at the checkpoint's top level and the durable-dir fs
image under fs/, and 'runsc restore -split-fsrestore' reads both halves
from -image-path.

atelet stages a DATA_ON_GOLDEN gVisor restore as one folder shaped like
a Full split snapshot whose fs half is the actor's: the golden's files
minus its fs/ contents at the top level, and the actor's flat
fscheckpoint image set re-rooted into fs/, overriding it wholesale
(micro-VM keeps its flat shadow-merge). Staging is subdir-aware —
parent directories are created once per distinct dir (ensureParentDirs)
on the download, local-copy, and pause-move paths — and gVisor combines
require the actor's and golden's pinned runsc to match: the images are
runsc-version-coupled, unlike the micro-VM durable tar.

ateom-gvisor lists snapshot files recursively so the fs/ half ships
with the manifest, passes the fs image at create/restore time when the
fs/ folder exists, and restores DATA_ON_GOLDEN through the Full path.
The CRD gate restricting onResume.fromData: Golden to microvm is
lifted, and the counter demos exercise the flow (the gvisor
SandboxConfig temporarily pins a split-checkpoint runsc build).
Dmitry Berkovich (dberkov) added a commit to dberkov/substrate that referenced this pull request Aug 11, 2026
Add an AteomHerder RPC that copies a paused actor's local checkpoint from
the node's disk to object storage. Unlike Checkpoint it drives no ateom:
the sandbox is gone; the files and their self-describing manifest already
sit under the actor's local-checkpoints directory.

- The manifest's recorded scope is authoritative for what the pause
  captured; a scope-less manifest (older atelet) is rejected rather than
  guessed at. The request only carries the desired (commit) scope.
- Scope conversion dispatches per sandbox class: a micro-VM FULL capture
  narrows to a DATA upload by carving out durable-dir.tar (constant hoisted
  to ateompath, shared with ateom-microvm); gVisor returns Unimplemented
  until split checkpoints land (agent-substrate#790); DATA can never widen to FULL.
- Idempotent retry: local files gone + remote manifest present means a
  previous invocation committed, and succeeds; gone on both sides is
  unrecoverable data loss (new LOCAL_SNAPSHOT_GONE reason, crashes the
  actor). Upload failures stay plain retryable errors - the local files
  are intact and object names deterministic.
- The manifest uploads last as the commit marker, never in parallel.
- The golden atespace is rejected: golden actors are never paused.

Dead code until the control-plane commit wires SuspendActor to call it.

Part of agent-substrate#791
Haven Xia (HavenXia) pushed a commit that referenced this pull request Aug 11, 2026
Part of #791 — the last planned piece of the [implementation
plan](#791 (comment))
(after #810, #812, #813). #791 stays open until #817 (gVisor
Full-capture → Data-commit conversion, blocked on #790) is done; this PR
covers micro-VM fully and gVisor for scope-matched suspends. Also part
of the actor state machine (#119) and a prerequisite for system upgrade
flows (#473).

`SuspendActor` now accepts a PAUSED actor: instead of checkpointing a
running workload, ateapi dials the atelet on the node holding the pause
snapshot and has it upload the node-local files to object storage, then
finalizes as usual — durable `ActorSnapshot`, `SUSPENDED` status, node
pinning cleared.

Two commits, reviewable independently:

## Commit 1 — atelet: `UploadPausedCheckpoint` RPC (dead code until
commit 2)

- New `AteomHerder` RPC: a pure disk→object-storage copy driven by the
snapshot's self-describing manifest — no ateom involved (the sandbox is
gone).
- **Scope conversion** dispatches per sandbox class
(`narrowFullCaptureToData`): a micro-VM FULL capture narrows to a DATA
upload by carving out `durable-dir.tar` (constant hoisted to
`ateompath`, shared with ateom-microvm); gVisor returns `Unimplemented`
until split checkpoints land (#790); DATA can never widen to FULL; a
scope-less manifest (older atelet) is rejected rather than guessed at.
- **Idempotent retry**: local files gone + remote manifest present ⇒ a
previous invocation committed, succeed; gone on both sides ⇒
unrecoverable (`LOCAL_SNAPSHOT_GONE`, crashes the actor). Upload
failures stay plain retryable errors; the manifest uploads last as the
commit marker, never in parallel.
- The golden atespace is rejected at validation (fully on the
`field.ErrorList` framework): golden actors are never paused.

## Commit 2 — control plane: enable suspend from PAUSED

- `FromPaused` discriminator: PAUSED status, or SUSPENDING with no
worker assignment and a `LocalSnapshotInfo` — the field alone is stale
on resumed-from-pause RUNNING actors, so the nil-assignment conjunct is
load-bearing.
- `MarkSuspendingStep` accepts PAUSED and rejects a Data-captured pause
against a Full commit *before* the actor leaves PAUSED (an upload cannot
fabricate memory), using the `content_scope` recorded at pause (#812)
with an `onPause` fallback.
- `CallAteletSuspendStep` paused branch dials by node
(`DialForAteletOnNode`, #813): missing node record ⇒ crash (the snapshot
can never be found); unreachable atelet ⇒ retryable; atelet's
`LOCAL_SNAPSHOT_GONE` ⇒ crash via `maybeCrashActor`.
`FinalizeSuspendedStep` needed no changes thanks to the #813 hoist.
- Root-cause guard: `MarkPausingStep` rejects pausing golden-atespace
actors.
- Docs: pause states + the new `PAUSED → SUSPENDING` edge in the
architecture state diagram; glossary Suspend entry covers both origins.

## Tests

- **atelet unit**: 10 upload-helper subtests (conversion matrix,
idempotency probe, data-loss crash, retryable upload failure) via a
recording object-storage fake; validation table.
- **control-plane unit**: discriminator table, scope-rejection table
(incl. onPause fallback), paused preconditions (no node ⇒ CRASHED, no
atelet ⇒ `ErrNoAteletOnNode` + still SUSPENDING), golden-pause
rejection, prerequisite matrix updated.
- **functional (envtest)**: `TestSuspendActor_FromPaused` (upload called
with the pause snapshot name, no Checkpoint RPC, SUSPENDED, pinning
cleared, ActorSnapshot at the upload destination) +
retry-after-failed-upload (same destination on retry).
- **e2e (demo suite)**: the lifecycle driver gains a suspend-from-PAUSED
mode; three durable-dir cases — Full/Full, Data/Data, and the micro-VM
Full→Data extraction — assert memory/file counters survive the full
pause→suspend→resume journey and the node pinning is gone.

`go test -race ./...` clean (except the pre-existing macOS-only
`internal/atunnel` unix-socket-path failures, untouched by this PR),
`gofmt`/`go vet` clean, protos regenerated via `hack/protoc.sh`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@bowei Bowei Du (bowei) added kind/feature An enhancement / feature request or implementation area/gvisor area/node labels Sep 17, 2026
@dberkov

Copy link
Copy Markdown
Collaborator Author

resume on data_on_golden feature has been reverted as part of the #2027.

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

Labels

area/gvisor area/node kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants