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:
-
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.
-
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.
-
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.
-
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.
-
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.
Background
Currently, urunc chooses the guest rootfs in the runtime path, inside
chooseRootfs(), shortly beforeExec()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.RootfsParamsto 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:
Rootfs mount timing
Runtime-side block-rootfs detection currently uses
getMountInfo(bundle/rootfs). However, the shim wrapper runs before the wrapped runc task service mountsr.Rootfsintobundle/rootfs, sobundle/rootfsmay not be mounted yet.Shim-side logic may need to use
CreateTaskRequest.Rootfsor containerd snapshot metadata instead.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 fromconfig.json, image metadata,urunc.json, and/etc/urunc/config.toml.State handoff
The shim cannot pass the result through memory. If it writes the selected
types.RootfsParamsintoconfig.json,urunc createmust also copy that information intostate.json, becauseExec()later reads fromstate.json.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.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.