runsc checkpoint, Firecracker snapshots, or Agent Substrate’s suspend.
What survives
A memory snapshot captures the whole sandbox, so everything axed holds comes back:- every process, running or finished, with its id, name, labels and exit status,
- every output log, with the same offsets,
- every stdin offset,
- the process table’s
instance_id, - the listeners inside the sandbox.
Attach, Run, Watch and Files.Write break, and some platforms (Agent Substrate) cancel them before the snapshot is taken. A replace or create-only upload that had not committed leaves nothing behind. Clients must start watches again.
Reconnect a client
1
Remember where you were
While attached, keep the process id and the offset one past the last output byte you received (
Output.offset plus the length of data).2
Check the instance
After reconnecting, call
System.Info and compare its instance_id with the one you saw before. If it changed, the sandbox cold-booted. The old processes are gone and their ids return NOT_FOUND.3
Reattach from your offset
gap event if some were evicted in the meantime. See The output log.4
Retry writes safely
Retry a start or an
Exec with the same request_id and a stdin write with the same offset, and axed acknowledges work that already happened instead of repeating it. A process id you kept from before the snapshot can carry the instance_id you saw: if the sandbox cold-booted instead of restoring, the call fails with NOT_FOUND and reason INSTANCE_CHANGED. See Start processes and Terminals and input.How axed detects a resume
Because platforms snapshot without calling into the guest, axed detects resumes itself. A background thread samples three clocks every second:CLOCK_MONOTONIC, CLOCK_BOOTTIME and CLOCK_REALTIME. Each pattern below counts as a resume:
Each detected resume increments
generation and records its time in resumed_at (the most recent 16). System.Info reports both; axectl info shows generation:
Timeouts count running time
A process timeout measures the time the sandbox ran: monotonic time minus the frozen time axed detected. When a timer fires, axed samples the clocks again before killing, so a timer woken by a VM resume does not kill on the spot. A process started with a 20 s timeout and suspended for an hour still gets 20 s of running time. See Signals, exits and limits. Time spent stopped bySystem.Freeze is not suspended time. The sandbox keeps running, so it counts toward timeouts.
Before a snapshot: Freeze
System.Freeze stops every process tree through its cgroup (cgroup.freeze), so nothing changes state while the platform captures memory. That includes background jobs a finished command left running, as an Agent Sandbox command does. It waits for every tree to change state, up to timeout (0 means 5 seconds), and returns changed and total, the number of trees that had tasks in them.
- axectl
- gRPC
- Freeze needs cgroups. Without them it fails with
FAILED_PRECONDITION. - A
changedlower thantotalmeans some trees did not finish changing state within the timeout. - Until the thaw, axed refuses to start processes, on every API, with
FAILED_PRECONDITION(FROZEN), so nothing runs while the rest are stopped. Starts already under way finish first and are frozen with the rest.System.Healthreportsfrozen. - The frozen state is part of the snapshot. Thaw after you restore, with
Freezeor withthawinConfigure, or the processes stay stopped and starts stay refused.
After a restore: Configure
System.Configure hands axed state that only the host knows. Call it after every restore on platforms whose clocks do not reveal the resume.
The response carries
clock_correction (positive when the clock moved forward), the new generation, entropy_added, which says whether the kernel took the entropy, and thawed, the trees thaw thawed.
axectl resumed sends the local wall time, 64 bytes of fresh entropy, and resumed: true:
axectl resumed uses the clock of the machine where axectl runs, so run it on the host or wherever the time is right.
Platform notes
gVisor
gVisor
gVisor’s clocks reveal the suspend on their own. Boot time includes it and monotonic time does not, so detection is automatic and timers are unaffected. gVisor offers no delegated cgroup, so
Freeze is not available. After a checkpoint and restore, a detached process keeps running, replay from offset 0 is intact, generation becomes 1 with a gap about as long as the suspension, and a timeout fires after its full running time. See gVisor.Firecracker
Firecracker
Firecracker freezes the guest’s clocks across a snapshot, so timeouts stay right without help, but the guest’s wall clock falls behind and nothing in the clocks reveals the resume. Call
System.Configure (axectl resumed) after every restore: it steps the clock, adds entropy and records the resume. Clients reconnect through the surviving vsock listener. axed manages the guest’s cgroup v2 hierarchy there, so Freeze is available. See Firecracker.Cold boot fallback
Cold boot fallback
Some platforms, Agent Substrate among them, restore from the persisted disk instead of memory when a memory snapshot is not available. That is a cold boot. axed starts fresh with a new
instance_id and generation 0, and process ids from before return NOT_FOUND. Files on the persisted disk remain. Compare instance_id on every reconnect to tell the two cases apart. See Agent Substrate.Eviction
Eviction
A platform that sends SIGTERM before suspending would normally make axed shut down. Start axed with
--on-sigterm=stay to keep it running instead; System.Health then reports eviction_pending: true, and axectl info shows pending on its eviction line. SIGINT always shuts down.
