guest: use OCIBundlePath as sandbox root source of truth#2653
guest: use OCIBundlePath as sandbox root source of truth#2653shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
bbc4d4d to
7deb168
Compare
a67564e to
9de87ec
Compare
rawahars
left a comment
There was a problem hiding this comment.
Overall love the simplification of the virtual pod vs normal pod differentiation.
Major comments are regarding keeping existing utility methods, while removing virtual pod specific ones and then changing these methods to return paths/values which you are creating on the fly. That would make it easier to review too.
|
@anmaxvl Can you please take a look too to see if any invariant of Security Policy gets impacted with this change. As I see it that should not change but please do confirm that. |
|
@micromaomao as well. |
I will have a closer look tomorrow, but I think this is probably good because #2581 added validation to |
c7fcebd to
e1f8a6f
Compare
|
@rawahars Addressed all 8 review comments. Also added Do you think this script is worth keeping in the repo for manual validation, or should it go in a separate PR / be dropped from this one? |
rawahars
left a comment
There was a problem hiding this comment.
Major driving comment are that for the current change, try to align as close to original code structure as possible.
e1f8a6f to
0fb9f0b
Compare
|
Thanks for the detailed round 2 review. Pushed an update addressing all the comments:
All tests pass locally (unit + E2E via crictl). |
08c0b9e to
7c4f900
Compare
helsaawy
left a comment
There was a problem hiding this comment.
Can we switch entirely to the *FromRoot functions and delete the [VirtualPodAware]*MountsDir/Source functions in internal/guest/spec?
7c4f900 to
003e8b3
Compare
003e8b3 to
c73b7f3
Compare
| } | ||
|
|
||
| // remove user mounts in sandbox container - use virtual pod aware paths | ||
| if err := storage.UnmountAllInPath(ctx, specGuest.VirtualPodAwareSandboxMountsDir(c.id, virtualSandboxID), true); err != nil { |
There was a problem hiding this comment.
Are we planning on removing VirtualPodAwareSandboxMountsDir and other utility methods in next PR?
There was a problem hiding this comment.
Yes, the follow-up PR (guest-pod-unification branch) removes VirtualPodAwareSandboxMountsDir and the other VirtualPod* methods as part of the unified pod model.
| // Set cgroup path | ||
| virtualSandboxID := spec.Annotations[annotations.VirtualPodID] | ||
| if virtualSandboxID != "" { | ||
| // Standalone container in virtual pod goes under /containers/virtual-pods/{virtualSandboxID}/{containerID} |
There was a problem hiding this comment.
nit: Consider adding this comment in next PR when you do the refactoring.
There was a problem hiding this comment.
Will add in the follow-up.
| // sandboxRoots maps sandboxID to the resolved sandbox root directory. | ||
| // Populated via RegisterSandboxRoot during sandbox creation using | ||
| // the host-provided OCIBundlePath as source of truth. | ||
| sandboxRootsMutex sync.RWMutex |
There was a problem hiding this comment.
nit: Why not just use the containersMutex? If sandboxRoots is always used under containersMutex then you can skip sandboxRootsMutex.
There was a problem hiding this comment.
Good point — sandboxRoots is only accessed within CreateContainer and RemoveContainer which both hold containersMutex. I'll consolidate to use containersMutex only in the follow-up to keep this PR minimal.
c73b7f3 to
a4dbd30
Compare
227430d to
ef409ba
Compare
helsaawy
left a comment
There was a problem hiding this comment.
Unsure about the container root path change, since it will break functional tests (e.g., TestLCOW_TeeLogPath), and probably several of our CRI integration tests too
internal/guestpath/paths.go
Outdated
| // LCOWRootPrefixInUVM is the path inside UVM where LCOW container's root | ||
| // file system will be mounted | ||
| LCOWRootPrefixInUVM = "/run/gcs/c" | ||
| LCOWRootPrefixInUVM = "/run/gcs/pods" |
There was a problem hiding this comment.
this will probably break a lot of our functional and cri tests that hardcode the /run/gcs/c as a container's bundle prefix.
There was a problem hiding this comment.
Good catch — reverted. LCOWRootPrefixInUVM stays as /run/gcs/c and hcsoci/create.go is unchanged from main. This PR now only touches the guest side: the GCS uses whatever OCIBundlePath the shim sends, making it path-agnostic. No shim-side changes needed.
internal/guest/runtime/runc/utils.go
Outdated
| func getLogDir(bundlePath string) string { | ||
| return bundlePath | ||
| } |
There was a problem hiding this comment.
can we just delete this? its more confusing to keep it since its basically the identity function
There was a problem hiding this comment.
Done — deleted getLogDir entirely. makeLogDir and getLogPath now use bundlePath directly.
Refactor the guest runtime to derive all sandbox paths from the host-provided OCIBundlePath rather than reconstructing them from hardcoded prefixes. This makes the GCS path-agnostic: it works with any OCIBundlePath the shim sends, regardless of prefix. Key changes: - runc.NewRuntime() no longer takes a base log path; runc.log is co-located with each container's bundlePath - Host.sandboxRoots map tracks the resolved sandbox root per container - CreateContainer registers sandbox roots; RemoveContainer cleans up - Sandbox, standalone, and workload container setup functions accept a resolved sandboxRoot parameter - New *FromRoot helpers in spec.go for sandbox subdirectory paths - runtime.Runtime.CreateContainer now takes sandboxID parameter Signed-off-by: Shreyansh Jain <shreyanshjain7174@gmail.com> Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
ef409ba to
57ce748
Compare
Guest-side GCS currently derives sandbox paths by combining a hard-coded prefix (/run/gcs/c) with the sandbox ID, ignoring the OCIBundlePath the host already sends. This breaks with Shim v2 path layouts and multi-pod UVMs.
This PR stores settings.OCIBundlePath as the canonical sandbox root on the Host struct (sandboxRoots map), and threads the resolved root through all setup and cleanup functions instead of re-deriving it.
For virtual pods, the sandbox root is derived from OCIBundlePath's parent directory (preserving the virtual-pods/ layout). For workload containers, it's looked up from the mapping. A legacy fallback ensures backwards compatibility with shim v1.
When the old shim sends OCIBundlePath in the legacy format, all paths are identical to before — verified by parity tests and a full CRI lifecycle (crictl runp/create/start/stop/rm) on a Hyper-V UVM.
Depends on: #2655 (bug fix for leaked LCOW resources) — both PRs modify uvm.go cleanup paths. Will rebase after #2655 merges.