SR: Phase 4: Full restore with incremental container adoption - #550
Merged
Roaa Sakr (romoh) merged 5 commits intoSep 18, 2026
Merged
Roaa Sakr (romoh) merged 5 commits into
Roaa Sakr (romoh) merged 5 commits into
Conversation
Copilot started reviewing on behalf of
Cameron E Baird (Camelron)
August 27, 2026 23:36
View session
There was a problem hiding this comment.
Pull request overview
Adds full snapshot restoration with live-container adoption, synthetic completion handling, identity mapping, and recursive snapshot support.
Changes:
- Records live/completed container identities and persists restore state.
- Adopts restored guest processes and refreshes node-local mounts.
- Adds restored rootfs/device lifecycle and agent mount-preparation APIs.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/runtime-rs/crates/runtimes/virt_container/src/sandbox.rs |
Builds and restores expanded snapshot manifests. |
src/runtime-rs/crates/runtimes/virt_container/src/sandbox_persist.rs |
Persists restore state. |
src/runtime-rs/crates/runtimes/virt_container/src/restore.rs |
Implements adoption, identity hashing, and completion tracking. |
src/runtime-rs/crates/runtimes/virt_container/src/container_manager/process.rs |
Separates host/guest process identities. |
src/runtime-rs/crates/runtimes/virt_container/src/container_manager/manager.rs |
Handles adopted and synthetic containers. |
src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container.rs |
Routes operations through guest IDs. |
src/runtime-rs/crates/runtimes/virt_container/src/container_manager/container_inner.rs |
Applies guest IDs to agent RPCs. |
src/runtime-rs/crates/runtimes/virt_container/Cargo.toml |
Adds SHA-256 support. |
src/runtime-rs/crates/runtimes/src/manager.rs |
Persists lifecycle transitions and emits events. |
src/runtime-rs/crates/runtimes/common/src/types/mod.rs |
Defines snapshot inventory types. |
src/runtime-rs/crates/runtimes/common/src/sandbox.rs |
Adds runtime-state persistence API. |
src/runtime-rs/crates/runtimes/common/src/container_manager.rs |
Adds synthetic completion API. |
src/runtime-rs/crates/resource/src/volume/share_fs_volume.rs |
Refreshes copied guest mounts. |
src/runtime-rs/crates/resource/src/volume/mod.rs |
Exposes snapshot mount metadata. |
src/runtime-rs/crates/resource/src/rootfs/snapshot.rs |
Rewrites recursive snapshot disk configuration. |
src/runtime-rs/crates/resource/src/rootfs/restored_rootfs.rs |
Implements restored rootfs lifecycle. |
src/runtime-rs/crates/resource/src/rootfs/mod.rs |
Registers and manages restored rootfs objects. |
src/runtime-rs/crates/resource/src/manager.rs |
Exposes restore resource operations. |
src/runtime-rs/crates/resource/src/manager_inner.rs |
Performs guest mount refreshes. |
src/runtime-rs/crates/hypervisor/src/lib.rs |
Adds restored-device removal API. |
src/runtime-rs/crates/hypervisor/src/device/device_manager.rs |
Delegates restored-device removal. |
src/runtime-rs/crates/hypervisor/src/ch/mod.rs |
Implements removal for Cloud Hypervisor. |
src/runtime-rs/crates/hypervisor/src/ch/inner_hypervisor.rs |
Documents paused restore/network behavior. |
src/runtime-rs/crates/hypervisor/src/ch/inner_device.rs |
Removes restored CLH devices by ID. |
src/runtime-rs/crates/agent/src/types.rs |
Defines guest-mount preparation request. |
src/runtime-rs/crates/agent/src/lib.rs |
Extends the agent interface. |
src/runtime-rs/crates/agent/src/kata/trans.rs |
Converts the new request type. |
src/runtime-rs/crates/agent/src/kata/agent.rs |
Registers the agent RPC. |
src/libs/protocols/protos/agent.proto |
Defines PrepareGuestMount. |
src/agent/src/rpc.rs |
Implements guest mount clearing. |
src/agent/src/netlink.rs |
Clarifies restored interface replacement. |
Cargo.lock |
Locks the SHA-256 dependency. |
Suppressed comments (2)
src/runtime-rs/crates/runtimes/src/manager.rs:723
delete_processhas already removed and cleaned the task before this save runs. If persistence fails, Delete returns an error and suppressesTaskDelete, but a retry seesContainerNotFound, leaving containerd unable to complete deletion. The durable state update and externally visible delete result need failure semantics that do not report a reversible failure after the irreversible mutation.
sandbox
.persist_runtime_state()
.await
.context("persist process deletion")?;
src/runtime-rs/crates/runtimes/src/manager.rs:830
- This save can fail after the process was resumed (or synthetically completed) and after
TaskStartwas published. Returning a Start error then contradicts the already-observed event and may cause containerd to retry a running task. Persist before publishing success where possible, or treat a post-commit save failure as a fatal recovery condition rather than a failed Start RPC.
sandbox
.persist_runtime_state()
.await
.context("persist container start")?;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+339
to
+343
| self.resource_manager | ||
| .cleanup_restored_rootfs(container_id) | ||
| .await | ||
| .context("detach deleted restored rootfs")?; | ||
| self.restore_context.retire_live(container_id).await; |
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
August 31, 2026 21:45
06d013b to
4508c9a
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 1, 2026 22:57
c9338f4 to
2afc1b3
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
2 times, most recently
from
September 4, 2026 23:17
4a0ec93 to
82f7cb9
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 9, 2026 18:51
82f7cb9 to
7d5c452
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
2 times, most recently
from
September 9, 2026 23:39
9e4a695 to
defed5a
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 10, 2026 18:45
defed5a to
134eb88
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 10, 2026 18:51
134eb88 to
f657dc7
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 11, 2026 19:03
f657dc7 to
0ce75d1
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 15, 2026 20:50
0ce75d1 to
089ecd3
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 15, 2026 23:01
089ecd3 to
3daac79
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 15, 2026 23:32
3daac79 to
34b9009
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 16, 2026 17:57
34b9009 to
367a9b7
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 16, 2026 19:14
367a9b7 to
35041e8
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 16, 2026 20:33
35041e8 to
af5a321
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
2 times, most recently
from
September 16, 2026 23:15
50dda97 to
851be9e
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
5 times, most recently
from
September 17, 2026 00:18
56716cd to
69df05a
Compare
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 17, 2026 16:35
69df05a to
1a4da9a
Compare
Base automatically changed from
cameronbaird/msft-main/phase3-rs-snapshot-restore-feature
to
msft-main
September 17, 2026 21:54
Add live and completed container accounting during the snapshot phase. This tells us which containers were naturally completed (init or ephemeral containers) and which are currently running (workload, pause). For live containers only, the restore path adopts the guest processes, storing mappings for the new containerd-provided ctr ids to the snapshotted instance's guest ids held by the agent. We then refresh the mounts and resume the cgroup, which was paused during snapshot. For incoming CreateContainers for completed containers, handle this synthetically. Respond with normal TaskStart and then TaskExit events. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com> Assisted-by: Sol 5.6
If a new container arrives after all live and completed contianters are accounted for from the snapshot manifest, allow them to proceed as new cold-started containers. This allows us to support ephemeral containers such as from kubectl debug --target=app... Signed-off-by: Cameron Baird <cameronbaird@microsoft.com> Assisted-by: Sol:5.6
Containers in a pod may be deployed with restartPolicy: Always or similar. In this case, we delete the old restored container and cold-start a replacement. However, this transaction didn't update the RestoreContext didn't recieve these updates, causing subsequent snapshot/restores to fail. Now at the point a container delete request lands in runtime-rs, we update the RestoreContext and hypervisor such that the old VMDK/disks are removed, and unplugged. When the restarting container cold-starts (a full Create-StartContainer), it becomes a Running and therefore a target of the snapshot path if one later occurs. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com> Assisted-by: Sol 5.6
For a given Pod with multiple instances of the same container image (e.g. 3 busybox containers inside one pod), kata deduplicates the number of disks attached to the VM, attaching only one disk for the three containers who reference it. We must account for this in the snapshot, deduplicating layers/disks. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com> Assisted-by: Sol 5.6
Skip runtime-state persistence after sandbox teardown has started and prevent cleanup from removing the persistence directory during a save. Bound best-effort Nydus unmount requests to five seconds and apply the deadline to the complete HTTP response. This prevents Nydus cleanup from blocking process-exit publication past the CRI StopPodSandbox timeout. Signed-off-by: Cameron Baird <cameronbaird@microsoft.com> Assisted-by: Sol:5.6
Cameron E Baird (Camelron)
force-pushed
the
cameronbaird/msft-main/phase4-rs-snapshot-restore-feature
branch
from
September 17, 2026 21:54
b0a1422 to
48f4fd8
Compare
Saul Paredes (Redent0r)
approved these changes
Sep 17, 2026
| #[async_trait] | ||
| impl Rootfs for RestoredRootfs { | ||
| async fn get_guest_rootfs_path(&self) -> Result<String> { | ||
| Ok("/run/kata-containers/shared/containers/restored/rootfs".to_string()) |
There was a problem hiding this comment.
nit: Use known global to construct this path.
Roaa Sakr (romoh)
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consume live and completed container accounting during the snapshot phase.
This tells us which containers were naturally completed
(init or ephemeral containers) and which are currently running
(workload, pause).
For live containers only, the restore path adopts the guest processes,
storing mappings for the new containerd-provided ctr ids to the
snapshotted instance's guest ids held by the agent. We then
refresh the mounts and resume the cgroup, which was paused during
snapshot.
For incoming CreateContainers for completed containers,
handle this synthetically. Respond with normal TaskStart and
then TaskExit events.