guest: unify pod model for V1, virtual pod, and V2 shim support#2699
Open
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Open
guest: unify pod model for V1, virtual pod, and V2 shim support#2699shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Replace the separate VirtualPod tracking (dedicated type, 7 exported
methods, parent cgroup manager, reverse-lookup map) with a unified
uvmPod type and a single pods map on Host. All pod types (V1 sandbox,
virtual pod, V2 shim) now go through the same code path:
- createPodInUVM allocates a cgroup under /pods/{sandboxID}
- addContainerToPod tracks container→pod membership
- RemoveContainer handles cleanup uniformly
Cgroup hierarchy changes from:
/containers/{id} (V1 sandbox)
/containers/virtual-pods/{virtualPodID} (virtual pod)
to:
/pods/{sandboxID} (all pod types)
Workload containers nest under their pod:
/pods/{sandboxID}/{containerID}
Signed-off-by: Shreyansh Jain <[email protected]>
Signed-off-by: Shreyansh Sancheti <[email protected]>
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.
The GCS guest runtime (
internal/guest/runtime/hcsv2/uvm.go) tracks virtual pods separately from V1 sandbox containers — a dedicatedVirtualPodtype, seven exported methods, a parent cgroup manager, and a reverse-lookup map. V1 sandboxes have no pod-level tracking at all. Adding V2 shim support would need a third path.This collapses all three into one: a private
uvmPodtype and a singlepodsmap onHost. Every sandbox — V1, virtual pod, or V2 shim — goes throughcreatePodInUVM, which allocates a cgroup under/pods/{sandboxID}. Workload containers nest at/pods/{sandboxID}/{containerID}. Container-to-pod membership is tracked viaaddContainerToPod. Cleanup inRemoveContaineris a single code path: remove the container from the pod, and when the sandbox container itself is removed, delete the pod's cgroup.Cgroup hierarchy changes from:
to:
Standalone (non-CRI) containers keep their own cgroup at
/pods/{id}with no pod entry — same isolation as before, just under the new prefix.Network namespace teardown for virtual pod sandboxes is preserved:
RemoveContainerskipsRemoveNetworkNamespacefor virtual pod sandbox containers since the host-driven path (TearDownNetworking→RemoveNetNS→removeNIC) handles adapter removal first.cmd/gcs/main.goreplaces the/containers/virtual-podsparent cgroup with/podsand drops theInitializeVirtualPodSupportcall.Tested E2E with both shims:
io.containerd.runhcs.v1)io.containerd.lcow.v2)/run/gcs/c/<podId>/run/gcs/pods/<podId>/<podId>/sys/fs/cgroup/memory/pods/<podId>/sys/fs/cgroup/memory/pods/<podId>/containers/virtual-pods/