Skip to content

guest: unify pod model for V1, virtual pod, and V2 shim support#2662

Open
shreyanshjain7174 wants to merge 2 commits intomicrosoft:mainfrom
shreyanshjain7174:guest-pod-unification
Open

guest: unify pod model for V1, virtual pod, and V2 shim support#2662
shreyanshjain7174 wants to merge 2 commits intomicrosoft:mainfrom
shreyanshjain7174:guest-pod-unification

Conversation

@shreyanshjain7174
Copy link
Copy Markdown
Contributor

@shreyanshjain7174 shreyanshjain7174 commented Apr 6, 2026

Depends on #2653 — must merge first.

The GCS guest runtime (internal/guest/runtime/hcsv2/uvm.go) tracks virtual pods separately from V1 sandbox containers — dedicated virtualPods map, VirtualPod type, reverse lookup table, parent cgroup manager, and seven pod-specific methods. V1 sandboxes have no pod-level tracking. The V2 shim would need a third path.

This collapses all three into one: a private uvmPod type and a single pods map on Host. createPodInUVM allocates a cgroup under /pods/{sandboxID} for any pod type. addContainerToPod tracks which containers belong where. The virtual-pod-specific API surface is gone — callers go through the same path regardless of pod flavor.

Cgroup management uses the unified cgroup.Manager interface so it works on both cgroupv1 and v2 hosts.

Replace heuristic sandbox path derivation (hard-coded /run/gcs/c prefix + ID)
with host-provided OCIBundlePath as the canonical sandbox root directory.

This change prepares the guest-side GCS for Shim v2 and multi-pod UVM support,
where the host may use a different path layout than the legacy /run/gcs/c/<id>.

Key changes:
- Add sandboxRoots mapping on Host to store resolved sandbox root per sandbox ID
- Sandbox containers: register OCIBundlePath as sandbox root
- Virtual pods: derive sandbox root from OCIBundlePath parent + /virtual-pods/<id>
- Workload containers: resolve sandbox root from Host mapping (fallback to legacy)
- Standalone containers: use OCIBundlePath directly as root
- Container.Delete: use stored sandboxRoot for cleanup paths
- Remove duplicate setup functions (setupVirtualPod* merged into unified setup*)

The refactor produces identical paths when the old shim sends OCIBundlePath in
the legacy format, ensuring zero behavior change for existing deployments.

Security: virtualPodID is validated against path traversal before use.
Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
@shreyanshjain7174 shreyanshjain7174 requested a review from a team as a code owner April 6, 2026 10:09
Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
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.

1 participant