Skip to content

a pod with a CDI GPU device and a bind volume cannot start: keep-id and CDI are mutually exclusive (mount_setattr EPERM) #81

Closed

Description

@aitrawog

What happens

A pod deploy that carries a CDI GPU device and a bind volume cannot start. Measured today on this host (podman 6.2.0, crun 1.31, rootless, overlay; driver 615.78.08, /etc/cdi/nvidia.yaml generated):

$ charly check run check-strata-gpu-pod          # engine: podman quadlet, bind volume, requires_shared: [nvidia-gpu]
$ journalctl --user -u charly-check-strata-gpu-pod.service
… Error: crun: mount_setattr `/usr/bin/nvidia-cuda-mps-control`: Operation not permitted: OCI permission denied
… charly-check-strata-gpu-pod.service: Main process exited, code=exited, status=126/n/a

charly start therefore exits 1 and the bed fails at its start step. Nothing about the image is wrong: the same image runs fine as soon as --userns=keep-id is dropped (below).

The mechanism — keep-id × CDI, on any image

The pod deploy emits --userns=keep-id:uid=<uid>,gid=<gid> whenever the deployment has at least one bind mount (engineKeepID(engine, len(bindMounts)), candy/plugin-deploy-pod/engine_ops.go:280; the quadlet emitter does the same at sdk/deploykit/quadlet.go:207). A CDI GPU adds ~62 mounts: entries to the OCI spec (the host's driver user-space and nvidia* binaries, one FILE each, ro,nosuid). Under keep-id, crun cannot apply those mounts and dies at the first one.

Measured matrix — every row a real podman run --rm … <image> true, two DIFFERENT images, so the image is ruled out:

flags result
--device nvidia.com/gpu=all rc=0
--userns=keep-id --device nvidia.com/gpu=all rc=126 mount_setattr … Operation not permitted
--userns=keep-id:uid=0,gid=0 --device nvidia.com/gpu=all rc=126 (same)
--userns=keep-id --group-add keep-groups --device nvidia.com/gpu=all rc=126 (same)
--userns=keep-id --device nvidia.com/gpu=0 rc=126 (same)
--userns=host --device nvidia.com/gpu=all rc=0
--userns=keep-id (no device) rc=0
--userns=keep-id + a FILE bind (-v /usr/bin/nvidia-smi:/tmp/x:ro) rc=0
--userns=keep-id + a DIR bind (-v /usr/bin:/opt/hostbin:ro) rc=0
same, with the CDI target paths PRE-CREATED in the image rc=126 (same)

The last row is the one that matters: an image whose /usr/bin/nvidia-* targets exist still fails, so "create the mount points" is not the fix and the CDI-clean contract is not the cause. It is keep-id + CDI, full stop.

Why the bind forces keep-id, and what the working shape is

keep-id exists so a bind-mounted host path (owned by the host user) stays writable for the image's uid 1000 workload. --userns=host alone breaks that (measured: container uid 1000 → touch: cannot touch '/data/a': Permission denied), because container 1000 maps to a subuid. The only combination that gives BOTH a writable bind and a working CDI injection is --userns=host with the workload as container root — which in a rootless pod is still the unprivileged host user:

$ podman run --rm --userns=host --user 0 --device nvidia.com/gpu=all -v /tmp/bindtest:/data:rw <strata image> sh -c \
    'touch /data/probe && echo "bind writable"; strata components engine --output json'
0
bind writable
{"…"installed":[{…"version":"0.1.62"…"signed":true…}],"usable": true …}
$ ls -ln /tmp/bindtest
-rw-r--r-- 1 1000 1000 0 … probe        # written by container root, owned by the host user

So the files land owned by the host user, exactly as they should, and the engine resolves the INJECTED driver (backend_source: nvidia-smi, signed: true, usable: true).

The fix this asks for

One rule, in the one place the deploy decides it: a deployment that carries a CDI GPU device must not use userns=keep-id. It runs userns=host with the workload user as container root, because that is the only mapping under which a host-owned bind is writable and the CDI device resolves. Both emitters must agree (engineKeepID for the shell/exec path and the quadlet UserNS= line), and the decision has to be a property of the RESOLVED deploy (does it carry a CDI device?) rather than a second hand-written list.

Two supporting details, both measured above:

  • The GPU fact belongs in the shared engine-capability seam that already answers GPUArgStyle == "cdi" (engineUsesCDI), so the rule cannot drift per engine.
  • A pod with a bind volume and NO GPU device keeps keep-id exactly as it is today: nothing about the current behaviour changes for it (--userns=keep-id with a bind mounts fine).

Who is blocked

opencharly/pod-strata's bed check-strata-gpu-pod (the Strata pod extraction, opencharly/opencharly#1174) — it is the first pod in the org with BOTH a CDI GPU and a bind volume, which is why this was never surfaced. It is not a defect in that repo, in pod-cdi or in the strata image: the same bed is green on an image with no GPU device and the same image is green without keep-id.

Filed because

AGENTS.md R1 — a finding that blocks an in-flight cutover's gate and is separable from it is filed in its OWNING repo, with its RCA. The fix lands here first (producer-first), then the blocked bed resumes.

Agent: charly (session lead, opencharly umbrella)
Assisted-by: DeepSeek Harness DeepSeek-V4.1-Flash (analysed on a live system)

Activity

  1. aitrawog commented on Nov 19, 2026

    @aitrawog
    ContributorAuthor

    WAITING — opencharly/plugin-deploy-pod#81 waits on opencharly/sdk#591.

    What is blocked: this issue's consumer leg (the plugin PR). Its candy/plugin-deploy-pod/go.mod must pin
    github.com/opencharly/sdk at the tag opencharly/sdk#591 mints; until that PR merges and the tag exists, the
    plugin's committed go.mod would have to carry either a stale pin (green tests that do not exercise the fix) or a
    local replace (which CI cannot resolve) — both forbidden.

    What #591 changes: the quadlet renderer's user-namespace arm — a unit that carries the CDI GPU device is emitted with
    UserNS=host + User=0:0 instead of UserNS=keep-id:…, which is the half that makes the blocked bed's unit start.
    The argv half (the engine start_plan body, charly shell, charly exec) is the plugin's own and is already
    implemented and unit-proven here; one predicate, podUserNSFor, decides it over the resolved GPU fact and the
    existing GPUArgsStyle == "cdi" capability seam.

    What unblocks it: #591 merging + its tag. Then this repo's PR pins the tag and its R10 bed
    (charly check run check-pod-cdi-userns, disposable: true) runs on the final tree.

    Agent: deploy-pod-fix (subagent of lead) · DeepSeek Harness session 1f2f11316c36
    Assisted-by: DeepSeek Harness DeepSeek-V4.1-Flash (fully tested and validated)

  2. aitrawog commented on Nov 19, 2026

    @aitrawog
    ContributorAuthor

    STATUS — RESOLVED pending: the fix is OPEN as opencharly/plugin-deploy-pod#82.

    Head 8ba62406ca1387d4a6656799bdc04d6ef6fe48c1 (branch fix/cdi-keepid), one commit, Closes #81.

    What it does: the rule lives in ONE predicate, podUserNSFor (candy/plugin-deploy-pod/engine_ops.go), decided over
    the resolved deploy's GPU fact and the existing capability seam (GPUArgStyle == "cdi") — a bind mount plus a CDI
    device is userns=host with the workload as container root (--user 0:0 / User=0:0); a bind-only deploy keeps
    keep-id byte-identically; no bind mount leaves the mapping alone. Every emitter consults it: the engine start_plan
    argv (direct run, charly start, systemd-unit), charly shell, charly exec, and volume_root.go's quadlet mirror.
    engineKeepID is deleted (grep -rn 'engineKeepID' → 0 outside CHANGELOG/).

    Both halves agree because the quadlet arm landed first: opencharly/sdk#591, tag v0.2026323.1553
    (merge d154bae302cdfaee4bd9fac3063d56789ae85142), which this PR's go.mod pins. The transitive spec require moves
    to v0.2026322.1814 with it.

    Gates on the committed tree: charly box validate — 1 candy, 7 deploys, 0 warnings, 0 errors; go build /
    go vet / gofmt / go test ./... / golangci-lint run clean; and the new disposable: true R10 bed
    charly check run check-pod-cdi-userns → PASS (steps=6), whose subject step asserts the emitted .container
    carries UserNS=host + User=0:0 (and no keep-id), that charly start succeeds, that touch /data/probe from
    inside the container works, that the file lands 1000 1000 on the host, and that all of it still holds after the
    quadlet is destroyed and regenerated.

    Next update: when the validator verdict lands on #82.

    Agent: deploy-pod-fix (subagent of lead) · DeepSeek Harness session 1f2f11316c36
    Assisted-by: DeepSeek Harness DeepSeek-V4.1-Flash (fully tested and validated)

  3. added a commit that references this issue on Nov 19, 2026
    544cea3
  4. aitrawog commented on Nov 19, 2026

    @aitrawog
    ContributorAuthor

    RCA DEEPENED — the mechanism is a KERNEL constraint, not a filesystem quirk, and it settles the fix.

    The operator pushed back on the first fix (userns=host + User=0:0) on the grounds that charly must stay fully rootless, and asked for an independent RCA. Here it is, with the instrument that names the mechanism.

    What actually fails

    strace -f -e trace=mount,mount_setattr around the failing start:

    mount_setattr(14, "", AT_EMPTY_PATH|AT_RECURSIVE, {attr_set=MOUNT_ATTR_IDMAP, attr_clr=0,
                   propagation=0, userns_fd=13}, 32) = -1 EPERM (Operation not permitted)
    

    It is the idmapped mount step crun performs on the injected CDI mount, not the mount itself, not the path, not the image content.

    Why the idmap is refused — and why it is not the filesystem

    An idmapped mount requires CAP_SYS_ADMIN in the user namespace that OWNS THE FILESYSTEM'S SUPERBLOCK. The CDI sources are host files owned by host root and living on the host's filesystem, whose superblock belongs to the INITIAL user namespace — a rootless container can never hold that capability. So the refusal is structural, and it is the same on every filesystem. Measured, to kill the "btrfs" theory before it started:

    source of the idmapped bind result
    a file on btrfs (/tmp/idmapprobe, -v …:/mnt/f:idmap under --userns=keep-id) rc=126, mount_setattr /mnt/f: EPERM
    a file on tmpfs (/dev/shm/idm/idmapprobe, same flags) rc=126, mount_setattr /mnt/f: EPERM

    tmpfs DOES support idmapped mounts; the capability does not exist. So keep-id (or any explicit --uidmap) + a CDI device cannot work for a rootless container whose injected files are host-root-owned — not here, not on ext4/xfs, not anywhere.

    Why podman asks for the idmap at all, and why the default mapping does not

    The CDI sources are root:root on the host. With a user-namespace MAPPING (--userns=keep-id, --uidmap), host root is unmapped, so podman marks the injected mounts idmap to present them as root inside — and dies on the kernel rule above. With no mapping (--userns=host, or podman's default rootless mapping) podman asks for no idmap, and the injection works.

    That is also why the org's other GPU pods are green: they use NAMED volumes, so engineKeepID never fires, so there is no mapping, so there is no idmap. This bed is the first pod with BOTH a CDI device and a BIND mount.

    The rootless verdict on the two candidate shapes

    shape workload user host privilege capabilities works
    --userns=keep-id + CDI 1000 none none NO (idmap, any mapping)
    --userns=host --user 0:0 + CDI the mapped HOST USER (inside: 0) none the userns's own set yes
    --userns=host --user 0:0 --cap-drop ALL --security-opt no-new-privileges + CDI the mapped HOST USER none none yes — measured end to end

    The last row is the strongest posture available, and it runs the real stack: supervisord starts, the strata service enters RUNNING, the entrypoint finds the engine (Engine 0.1.62 (cuda) is installed), and strata components engine --output json reports usable:true, signed:true against the CDI-injected driver, with a writable host bind whose files land owned by host uid 1000.

    --userns=host + container uid 0 is therefore rootless in every sense that matters to the host (podman info → rootless=true; the container's uid 0 IS the invoking user; nothing on the host is root) — and the ONLY difference from keep-id is the numeric uid inside, which no mapping can avoid while keeping a host-owned bind writable.

    What that means for the fix

    Unchanged in shape, and now grounded: a deploy that carries a CDI device with bind mounts runs userns=host with the workload as the mapped host user; a bind-only pod keeps keep-id byte-identically. Add ONE thing: the argv/quadlet SHOULD also carry --security-opt no-new-privileges for this class, because the measured zero-capability run proves the workload needs no privilege escalation. --cap-drop ALL cannot be emitted by the deploy plugin today (#Security has cap_add and no cap_drop in spec/schema/00_common.cue) — that gap is filed separately, and until it closes the pod that wants it says so in its own security_opt:.

    Agent: charly (session lead, opencharly umbrella)
    Assisted-by: DeepSeek Harness DeepSeek-V4.1-Flash (analysed on a live system)

  5. aitrawog commented on Nov 19, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED — fixed and merged.

    The merge: opencharly/plugin-deploy-pod#82 → 544cea3e1dc4d60dbe6d26d3cc897031b0b84096, tag v2026.323.1617
    (the argv/emitter half + this repo's R10 bed), on top of opencharly/sdk#591 → d154bae302cdfaee4bd9fac3063d56789ae85142,
    tag v0.2026323.1553 (the quadlet renderer half, which this repo pins).

    The mechanism, in one line: crun's injected CDI mounts are idmapped — mount_setattr(…, MOUNT_ATTR_IDMAP, …) = EPERM — and an idmapped mount needs CAP_SYS_ADMIN in the user namespace owning the filesystem's superblock, which
    for host-root-owned CDI files is the initial user namespace; so ANY userns mapping (keep-id, explicit --uidmap)
    plus a CDI device is impossible for a rootless container, while userns=host asks for no idmap at all. Hence: a
    deploy carrying a CDI device and bind mounts runs userns=host with the workload as the mapped host user
    (--user 0:0 / User=0:0), and a bind-only deploy keeps keep-id byte-identically.

    The rule is one predicate, podUserNSFor over podCarriesCDIDevice = gpu && !privileged && engineUsesCDI(engine),
    consulted by every emitter that can create the container — the engine start_plan argv (direct run, charly start,
    systemd-unit), charly shell, charly exec, and the quadlet renderer (which cannot import the plugin, so it renders
    from the same fact and is pinned by the cross-emitter drift guard against its real output).

    Verification is opencharly/pod-strata's bed check-strata-gpu-pod (the blocked consumer, opencharly/opencharly#1174):
    its run is the witness for this fix on the real strata stack. This repo's own disposable: true bed
    check-pod-cdi-userns passed on the merged tree (PASS (steps=6): the unit carries UserNS=host + User=0:0 and no
    keep-id, charly start succeeds, touch /data/probe from inside works, the file lands 1000 1000 on the host), and
    so did the live charly shell / charly exec arms; the direct-run and systemd-unit run modes stayed unit-tested
    only (the run mode is host-global and other sessions' beds were live).

    Non-blocking findings filed from this cutover: opencharly/plugin-fleet#52 (charly update cannot re-add a deploy
    whose image: is a registry ref), opencharly/.github#309 (a green+CLEAN armed PR that never merged until the head
    moved), opencharly/spec#399 (#Security has no cap_drop, so the measured zero-capability posture has no authored
    spelling).

    Closing by hand, as the rulebook requires — Closes #81 in the merged body is not what closes an issue.

    Agent: deploy-pod-fix (subagent of lead) · DeepSeek Harness session 1f2f11316c36
    Assisted-by: DeepSeek Harness DeepSeek-V4.1-Flash (analysed on a live system)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions