Skip to content

ateworker: reuse completed checkpoint when workload is already stopped - #3015

Merged
Haven Xia (HavenXia) merged 1 commit into
agent-substrate:mainfrom
chw120:ateworker-reuse-completed-checkpoint
Oct 23, 2026
Merged

Haven Xia (HavenXia) merged 1 commit into
agent-substrate:mainfrom
chw120:ateworker-reuse-completed-checkpoint

Conversation

@chw120

Copy link
Copy Markdown
Collaborator

When atelet restarts (or loses the CheckpointWorkload response) after ateworker has already finished writing the snapshot into checkpoint-state/ and torn down the sandbox/VM, atelet has not yet moved checkpoint-state/ into local-checkpoints/<uuid>/ or recorded the snapshot in snapshottracker. When the control plane retries Checkpoint, the replacement atelet calls ateworker.CheckpointWorkload again against a workload that no longer exists (runsc checkpoint: exit status 128).

This PR records an atomic completion marker (checkpoint-state/.checkpoint-done.json) at the end of CheckpointWorkload in both ateworker-gvisor and ateworker-microvm. If a retry arrives when the workload is already unhosted (lookupActor(actorUID) == nil), ReuseCheckpoint verifies that the marker's fidelity matches and all listed SnapshotFiles / DataSnapshotFiles are still present in checkpoint-state/, returning the cached response immediately instead of re-running runsc checkpoint or cloud-hypervisor snapshot.

Once atelet moves the snapshot files into local-checkpoints/<uuid>/ or resets the actor directory via resetActorDirs, the marker is invalidated/removed automatically.

Part of #2836

  • Tests pass

Comment thread internal/ateworker/checkpoint.go Resolved
Record a completion marker (.checkpoint-done.json) inside checkpoint-state/ once CheckpointWorkload has written the snapshot files and torn down the workload. If a retry arrives after the workload is gone (for example when atelet restarts or loses the response before moving checkpoint-state/ into local-checkpoints/), ReuseCheckpoint returns the recorded SnapshotFiles and DataSnapshotFiles while they are still intact on disk instead of failing on a missing sandbox.
@chw120
Chenyi Wang (chw120) force-pushed the ateworker-reuse-completed-checkpoint branch from 6660eb1 to f84648d Compare October 23, 2026 20:34
@HavenXia
Haven Xia (HavenXia) added this pull request to the merge queue Oct 23, 2026
Merged via the queue into agent-substrate:main with commit a018a31 Oct 23, 2026
16 checks passed
@chw120
Chenyi Wang (chw120) deleted the ateworker-reuse-completed-checkpoint branch October 23, 2026 21:26
Max Thompson (thompsonmax) pushed a commit to thompsonmax/substrate that referenced this pull request Oct 28, 2026
…substrate#3213)

Follow-up to agent-substrate#3015. Part of agent-substrate#2836.

A retried CheckpointWorkload reuses the worker's record of a completed
checkpoint. The worker does not sync the snapshot files, so after a node
reboot the record and the files can survive with torn contents. The
retry then reused them, and atelet stamped the local snapshot with the
new boot ID, so its pre-reboot check no longer catches them.

- RecordCheckpoint records the node's boot ID, and ReuseCheckpoint skips
a record from another boot. After a reboot, the retry fails instead of
committing files that may be torn.
- atelet's boot ID reader moves to internal/bootid so the workers can
use it.

TestRecordAndReuseCheckpoint covers a record from another boot.

AI use: AI-assisted. I reviewed and tested it.

- [x] Tests pass

---------

Signed-off-by: Chenyi Wang <[email protected]>
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.

2 participants