Repository navigation
fix(deploy)!: never run a unit as container root - #640
Conversation
A unit with a bind mount now always runs as the IMAGE USER under UserNS=keep-id: the image user is the invoking host user there, so a host-owned volume is writable with no chown and nothing runs as root. The CDI device is emitted only on a unit WITHOUT bind mounts. Measured: keep-id + CDI fails at the spec's first file mount for the nvidia-ctk spec AND for a minimal devices+libs spec (crun mount_setattr EPERM, exit 126), while a devices-only CDI spec applies fine — so a bind unit takes its GPU as device-node injection plus driver-library bind mounts instead. userns=host --user 1000 with an idmapped volume is also denied; the old root branch is gone. Measured end to end in that shape: uid=1000, host bind written 1000:1000, cuInit/device/context/16 MiB alloc ok, nvidia-smi -L lists the GPU, and an ONNX Runtime MatMul executed on CUDAExecutionProvider with the model stored on a gocryptfs volume. gofmt/vet/test/golangci-lint (module toolchain go1.26.8): clean. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Review — BLOCKHead SHA: Change class: code/config — Go library change in Blocks
Notes (non-blocking)
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…ts mounts The first commit on this branch dropped the CDI device from every unit with a bind mount. That over-corrected: the measured wall is the CDI spec's `mounts` section, not the device. keep-id + stock /etc/cdi/nvidia.yaml (has mounts) -> crun mount_setattr /usr/bin/nvidia-cuda-mps-control: EPERM, exit 126 keep-id + a DEVICES-ONLY spec (same device name, deviceNodes only) + the driver libs bound to their SONAME paths -> user/uid 1000, device node present, cuInit=0 on the RTX 4080 SUPER So the emitter keeps `AddDevice=nvidia.com/gpu=all` on every GPU unit, bind or not; the caller (plugin-deploy-pod) supplies a devices-only spec and the library binds. The only rule the emitter enforces is the user-namespace one: keep-id as the image user, never UserNS=host with User=0:0. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Review — BLOCKHead SHA: Change class: code/config — Go library change in Security screen: PASS — no scope mismatch (the diff matches the stated intent: remove the root branch, keep the CDI device), no secrets/egress, no guardrail weakening, no supply-chain change, and this PR does not touch the validator spec or rulebook. Comment intake
Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
|
WAITING Round 1 — RCA and WAITINGRCA of the BLOCK. The validator was right on both counts, and both are mine:
WAITING on opencharly/plugin-deploy-pod#93. It blocks the This PR blocks opencharly/plugin-deploy-pod#94 (the consumer leg: devices-only CDI spec + driver-library binds). The sdk tag must merge first, so the plugin can pin it. Next update: 2026-11-25, or on either thread's next change, whichever comes first. Agent: Agent: |
…ordination The BLOCK was body-only: the consumer leg was named in prose instead of filed, and the thread carried no WAITING/HOLDING. Both are addressed (opencharly/plugin-deploy-pod#94 filed and cited; RCA + WAITING posted on this thread, HOLDING on #93 and #94). This commit exists to give the required validator a new head to judge; it changes no file.
Review — PASSHead SHA: Change class: code/config — Go library change in Security screen: PASS — no scope mismatch (diff matches intent: remove the root branch, keep the CDI device), no secrets/egress, no guardrail weakening, no supply-chain change, does not touch the validator spec or rulebook. Comment intake:
Checklist: All applicable rules PASS or NA. Notable verified items: A1 complete (both files accounted, pasted gate output, honest Non-blocking notes: (1) gate evidence names Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
|
HOLDING HOLDING opencharly/opencharly#1272 — the umbrella rulebook PR states the rootless rule and waits on this emitter fix for it to be true. No pin moves until this PR merges and tags, so production is unchanged in the interval. Next update: on this PR's next verdict, or 2026-11-25, whichever comes first. Agent: Agent: |
…e output Body-only round: the surfaced emitter defect is now under `## Filed issues` as opencharly/sdk#640 (R4/R1), the thread carries WAITING on that item (COORD), the pre-commit gate output is pasted rather than described (A1), and the harness/model pairing is evidenced from the session environment (A3). No file changes. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed)
…id GPU unit A keep-id unit needs two things the emitter could not express: the engine flag that points podman at a devices-only CDI spec (`--cdi-spec-dir`), and the driver libraries bound `:ro` to their SONAME paths. QuadletConfig gains PodmanArgs (emitted as ONE PodmanArgs= line, because quadlet splits that line into argv words) and ResolvedBindMount gains ReadOnly. Both are internal library inputs, no wire or schema change. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
* docs(rulebook): no charly pod runs as container root A deployment is rootless unless its stack declares `privilege: rootful` (D-HW-10), and a bind mount is not such a need. The rulebook now states the rule precisely: - a unit with a bind mount runs as the image user under `UserNS=keep-id:uid=<uid>,gid=<gid>` — under keep-id that user is the invoking host user, so a host-owned bind or gocryptfs plaintext directory is writable with no chown; - the GPU stays a CDI device on every GPU unit. What keep-id rejects is a CDI spec's `mounts` (crun `mount_setattr` EPERM, exit 126), never the device, so the deployment points the engine at a derived devices-only spec and binds the driver libraries read-only to their SONAME paths; - `userns=host` + `User=0:0` is a blocking defect, and `HOME`/`XDG_*` are never pinned to compensate for it. Detail lives in the owning skills: `/charly-distros:cdi`, `/charly-automation:enc`, `/charly-internals:xdg`. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed) * chore: round 1 — filed-issues entry, coordination comment, pasted gate output Body-only round: the surfaced emitter defect is now under `## Filed issues` as opencharly/sdk#640 (R4/R1), the thread carries WAITING on that item (COORD), the pre-commit gate output is pasted rather than described (A1), and the harness/model pairing is evidenced from the session environment (A3). No file changes. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed) * chore: round 2 — round RCA posted, footer and excerpt wording corrected The BLOCK was the missing review-round RCA; it is posted on the thread, with the missed control (the gate covered the diff, not the round) and the gate change. The body's gate excerpt is now labelled as the partial excerpt it is, and the duplicated footer on the coordination comment was trimmed. No file changes. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed)
Review — BLOCKHead SHA: Change class: code/config — Go library change in Blocks
Comment intake
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
|
STATUS Round 2 — RCAMechanism. The body and the gate evidence were written for the first commit and never re-derived after the second code commit ( Missed control. My pre-push gate ran once, at the moment the first commit was validated, and I treated "the gate passed" as a property of the PR rather than of the HEAD. Nothing in my procedure re-ran the gate after a later code commit on the same branch, and the body review I did was against my own summary of the branch, not against Blast radius. This PR's evidence only; no code, pin or runtime state. Root fix, applied. The body now accounts for every commit; the gate was re-run on the exact pushed head ( Next update: on the next verdict, or 2026-11-25, whichever comes first. Agent: Agent: |
…ushed head Body-only round: the Summary accounts for the second code commit, R11 states the two added internal fields and their disposition, and the module gate was re-run on the exact pushed head with the new test's output pasted. The round RCA is posted on the thread. No file changes. Agent: `immich-consolidation` · Claude Code session `113f762e-5d70-484a-9ed9-e34c6423c926` Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (diff matches the stated intent: remove the root branch, keep the CDI device, add Checklist: All applicable rules PASS or NA. Verified from the current body + diff: A1 (both files/behaviors accounted for; gate output pasted; real Comment intake:
Non-blocking notes: (1) the Summary labels the Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
… mounts cannot (#646) The carriesCDIDevice comment still says a unit that carries the CDI device cannot run under keep-id. That stopped being true with #640 and plugin-deploy-pod#97: a GPU unit with a bind mount rides keep-id, and the caller points the engine at a devices-only CDI spec, so the spec's file mounts never reach crun — the device does. Comment only; no behaviour change. Refs opencharly/opencharly#1287 *Agent: `cdi-audit` · Claude Code session `f760307f-53b4-4f48-87da-00f95e5300ed`* *Assisted-by: Claude Code deepseek-v4.1-flash:cloud (documentation reviewed)*
Summary
The quadlet emitter had one branch that ran a deployment's workload as container root: a unit that carried the CDI GPU device and had a host-owned bind mount was emitted
UserNS=host+User=0:0, because crun cannot apply the CDI spec's file mounts underkeep-id(opencharly/plugin-deploy-pod#81). The measurement behind that branch was right; the remedy was not. It made container root the emitter's default for a whole class of deployments, which is privileged by any reading of the requirement that governs it — D-HW-10: "A deployment is rootless unless a need in its stack isprivilege: rootful: its kind's grant runs it on the driver's rootless mode … with the box's workload as the box's user, and no other field, setting or default makes it privileged." A bind mount is not aprivilege: rootfulneed.The emitter now has no root branch: a unit with a bind mount runs
UserNS=keep-id:uid=<uid>,gid=<gid>as the image user. Under keep-id that user is the invoking host user, so a host-owned volume (a bind, or a gocryptfs plaintext directory) is writable as-is, with no chown.CDI stays. The device is emitted for every GPU unit, bind or not. The measured wall is the CDI spec's
mountssection, not the device: a devices-only spec (same device name,deviceNodesonly) applies normally inside keep-id. So the split of responsibility is:AddDevice=nvidia.com/gpu=all) and how the unit runs (keep-id, image user);plugin-deploy-pod— points the engine at a devices-only spec and supplies the driver libraries as read-only binds to their SONAME paths (both derived from the host's CDI spec, never baked into the image).The second commit on this branch adds the two inputs that caller needs and the emitter could not express:
QuadletConfig.PodmanArgs []string(rendered as ONEPodmanArgs=line — quadlet splits that line into argv words, so--cdi-spec-dir <dir>is one flag and its value together) andResolvedBindMount.ReadOnly bool(rendered:ro). Both are internal library inputs of the config-to-unit path; no wire type, CUE schema or CLI flag changes.Measured (podman 6.2.0, crun 1.31, rootless,
/etc/subuidatrawog:100000:65536, imageghcr.io/opencharly/immich-cdi):--userns=keep-id:uid=1000,gid=1000 --user 1000+ host bind--device nvidia.com/gpu=allresolved from the stock/etc/cdi/nvidia.yaml(it carriesmounts)crun: mount_setattr /usr/bin/nvidia-cuda-mps-control: Operation not permitted, exit 126--device nvidia.com/gpu=allresolved from a devices-only spec +libcuda.so.1,libnvidia-ml.so.1,libnvidia-ptxjitcompiler.so.1bound to their SONAME pathsuser/uid 1000, device node present,cuInit= 0on the RTX 4080 SUPER (ONNXMatMulprofiled onCUDAExecutionProviderin the same shape)--userns=host --user 1000+:idmapvolume (both-v src:dst:idmapand--mount …,idmap)userns=host-allow_othercrun: cannot stat …: Permission denied); with-allow_other, uid 1000 writes, file1000:1000How tested
The changed generator ran live, and its artifact is pasted. A throwaway harness called
GenerateQuadlet(the changed function) on the committed tree for a GPU deploy with a host-owned bind, and printed the unit:No
UserNS=host, noUser=0:0; the CDI device is present; the unit runs as the image user. The harness file was deleted after the run (the worktree is clean).The unit test fails without the change.
TestGenerateQuadletUserNS's first arm ("cdi device + bind: keep-id, the image user, and the CDI device") assertsUserNS=keep-id:uid=1000,gid=1000and the CDI device, and the absence ofUserNS=hostandUser=0:0; against the parent commit it fails on the two absent assertions. The second arm pins the plain-device-node shape, and the three regression arms (bind-only keep-id, privileged, GPU without bind) are unchanged.Gates on the pushed head (
5d4124a4aa85d0eaa683b1c3b0eb05cd94c1119d, clean worktree — the merge commitgh pr update-branchproduced, fast-forwarded locally so the gate ran the exact pushed tree):TestGenerateQuadletPodmanArgsAndReadOnlyBindasserts a GPU unit with a read-only library bind emitsPodmanArgs=--cdi-spec-dir <dir>as one line,Volume=<host>:/usr/lib/libcuda.so.1:ro,AddDevice=nvidia.com/gpu=allandUserNS=keep-id:uid=1000,gid=1000.R5 sweep (executed): the removed emission has no site left; the only hits are the test arms that assert its absence:
What did not run live, and why. The generated unit was not started through
charly config→ systemd, because (a)charly configcannot configure a deploy absent from the per-host config at all (opencharly/plugin-deploy-pod#93, blocking, filed), and (b) the consumer half —plugin-deploy-podselecting a devices-only CDI spec and emitting the library binds — is the NEXT leg and has not landed. The runtime behaviour was measured withpodman runand with the engine's own quadlet dry-run on the same host, image and userns configuration.Runtime (A3) — the authoring runtime's identification:
Rulebook compliance
/charly-internals:go,/charly-internals:design,/charly-core:deploy,/charly-check:check, this repo'sAGENTS.md.privilege: rootful. A first attempt (fix(deploy): pin HOME to the image home when the workload runs as container root #638) pinnedHOMEfor that root workload; it is superseded because it legitimised the root shape instead of removing it. The first commit on THIS branch then over-corrected by dropping the CDI device from bind units; the second commit corrects it on the measured distinction between the device and the spec's mounts, stated above.emitContainerSection);carriesCDIDeviceremains the single fact behind the CDI emission for every GPU unit.origin/main; no force-push, no push tomain.QuadletConfig.PodmanArgsandResolvedBindMount.ReadOnly(deploykitlibrary types, never crossing the host↔plugin boundary, no CUE schema, no wire form). D-LAW-2 is satisfied — each field has its producer (the deploy plugin's devices-only-spec leg) and its consumer (the emitter'sPodmanArgs=/:rorendering) in the same change, and the new test exercises both. No other field, kind, verb or capability is added, so there is no design debt to file.Change classification
The
!marker is correct: the unit generated for one class of deployments changes shape.Breaking change + rollback: a GPU deployment that also has a host-owned bind mount was generated
UserNS=host+User=0:0; it is now generated keep-id as the image user, with the same CDI device. Its GPU then requires the consumer leg —plugin-deploy-podpointing the engine at a devices-only CDI spec plus the driver-library binds — before it is regenerated, because the stock spec's mounts fail under keep-id (exit 126). No pin moves in this PR, so nothing in production changes until that consumer PR bumps this sdk tag; an operator who regenerates a bind+GPU deployment against this sdk alone gets a non-root workload whose container fails to start until the spec is devices-only. Rollback: revert the branch and re-runcharly configon the affected deployments — the previous units regenerate byte-identically.Consumer leg (order): this sdk PR → sdk tag → opencharly/plugin-deploy-pod#94 (devices-only spec + library binds, proven end-to-end on top of #93) → tag → charly's plugin pin → umbrella pin wave. The skill/documentation legs (
/charly-distros:cdi,/charly-automation:enc,/charly-internals:xdg) and the umbrella rulebook are updated to this rule in their own repos.Filed issues
charly configcannot configure a deploy absent from the per-host config: it persistsresolved_portbeforeimage:, and its own volume write then refuses the partial entry. This is why the liveconfig → systemdproof could not be run here.Agent:
immich-consolidation· Claude Code session113f762e-5d70-484a-9ed9-e34c6423c926Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)