Skip to content

Move guest rootfs selection earlier to the shim #684

@sidneychang

Description

@sidneychang

Background

Currently, urunc chooses the guest rootfs in the runtime path, inside chooseRootfs(), shortly before Exec() prepares the monitor environment.

For upcoming shim-side storage work, such as view snapshots or copy-boot-files mode, the shim needs to know this decision earlier.

Proposal

Pre-compute the guest rootfs choice in the shim when possible, then pass the selected types.RootfsParams to the runtime through internal annotations.

The runtime should still keep the existing chooseRootfs() logic as a fallback, so podman/direct urunc usage continues to work.

Main concerns

We cannot simply move the current chooseRootfs() implementation into the shim.

There are several issues:

  1. Rootfs mount timing

    Runtime-side block-rootfs detection currently uses getMountInfo(bundle/rootfs). However, the shim wrapper runs before the wrapped runc task service mounts r.Rootfs into bundle/rootfs, so bundle/rootfs may not be mounted yet.

    Shim-side logic may need to use CreateTaskRequest.Rootfs or containerd snapshot metadata instead.

  2. Different available state

    Runtime-side chooseRootfs() uses decoded annotations, urunc host config, guest capabilities, monitor capabilities, and rootfs mount information. In the shim, some of these inputs may not exist yet or may need to be reconstructed from config.json, image metadata, urunc.json, and /etc/urunc/config.toml.

  3. State handoff

    The shim cannot pass the result through memory. If it writes the selected types.RootfsParams into config.json, urunc create must also copy that information into state.json, because Exec() later reads from state.json.

  4. Compatibility

    urunc can also be used without this shim, for example through podman or direct urunc commands. Therefore, runtime-side chooseRootfs() must remain as a fallback when no shim-provided rootfs choice exists.

  5. Side effects

    The current rootfs selection path may also create or prepare paths such as bundle/monRootfs. If selection is pre-computed in the shim, we should avoid filesystem side effects during the selection phase and keep actual rootfs preparation in the runtime path.

Metadata

Metadata

Assignees

Labels

CoreRelated to urunc's internalsdevInvolves developmentenhancementNew feature or request

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions