Repository navigation
fix(quadlet): emit the CDI device once when security.devices repeats it - #645
Conversation
A caller that lists `nvidia.com/gpu=all` in `security.devices` on a GPU unit got the directive twice: `emitContainerSecurity` writes the implicit line for every GPU unit, then writes every `Security.Devices` entry verbatim. Two sources of truth for one directive, and it hides which one owns it (#643, measured in charly-ollama-cdi.container lines 16-17). One spelling for both: `CDIDevice`, used by the implicit line and skipped in the explicit list when it repeats it. Non-CDI entries are emitted unchanged. Regression test fails on the unmodified emitter ("CDI device emitted 2 times, want exactly 1") and passes with this change. *Agent: `qwen3-tts-vram` · Claude Code session `699080d3-3ff0-4337-afa4-94f960590338`* *Assisted-by: Claude Code Ollama Cloud deepseek-v4.1-flash (fully tested and validated)*
Review — BLOCKHead SHA: Change class: code (sdk Blocks
The fix logic itself is correct (implicit line and explicit-list dedupe both keyed on Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
A caller that lists nvidia.com/gpu=all in security.devices on a GPU unit got the directive twice: emitContainerSecurity writes the implicit line for every GPU unit, then writes every Security.Devices entry verbatim. Two sources of truth for one directive, and it hides which one owns it (#643, measured in charly-ollama-cdi.container lines 16-17). One UNEXPORTED spelling for both: cdiDevice, used by the implicit line and skipped in the explicit list when it would repeat it. Non-CDI entries are emitted unchanged; the privileged branch is untouched (a privileged unit never carries the CDI device). Round 2 (review): the constant was exported as CDIDevice in round 1 while the body called it internal — the body was right and the code was wrong, so it is unexported now, keeping the CDI string out of the sdk's public API. Regression test fails on the unmodified emitter ("CDI device emitted 2 times, want exactly 1") and passes with this change. *Agent: `qwen3-tts-vram` · Claude Code session `699080d3-3ff0-4337-afa4-94f960590338`* *Assisted-by: Claude Code Ollama Cloud deepseek-v4.1-flash (fully tested and validated)*
Review — PASSHead SHA: Security screen: PASS Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary
A GPU unit whose caller also lists
nvidia.com/gpu=allinsecurity.devicesgot the CDI device linetwice:
emitContainerSecuritywrites the implicit line for every GPU unit, then writes everySecurity.Devicesentry verbatim (#643; measured in~/.config/containers/systemd/charly-ollama-cdi.container, lines 16–17).The fix gives the device ONE spelling,
cdiDevice(unexported), used by the implicit line andskipped in the explicit list when it would repeat it. Non-CDI entries (
/dev/dri/renderD128, …) areunchanged, and the privileged branch is untouched (a privileged unit never carries the CDI device).
How tested
The regression test is the spike-equivalent (R12): it fails on the unmodified emitter and passes
with the fix.
Red — dedupe removed,
CDIDevicekept so the tree compiles:Green — the fix in place, and the whole package plus vet:
The neighbouring unit that pins the GPU shape is unchanged and passes:
TestGenerateQuadletPodmanArgsAndReadOnlyBind(it assertsPodmanArgs=--cdi-spec-dir …,Volume=…/libcuda.so.1:ro,AddDevice=nvidia.com/gpu=all,UserNS=keep-id:…).Rulebook compliance
/charly-internals:install-planand/charly-internals:gowere loaded; this is thesdk's quadlet emitter, the deploy-mode target's own code.
the code (implicit line + explicit list), not a guess.
git statuswas clean before the commit.the full package plus vet pass on the final tree.
go test ./deploykit/+go vet, run above; no disposable target isinvolved in a library emitter change.
cdiDeviceis an UNEXPORTEDpackage constant — not a wire type and not part of the sdk's public API. (Round 2: the first
revision exported it as
CDIDevicewhile the body called it internal; the code was the wronghalf, so it is unexported now.)
## How tested— the regression testfails on the unmodified tree (
CDI device emitted 2 times, want exactly 1) and passes with the fix.Change classification
once; podman treated both identically. Rollback is reverting the commit.
Filed issues
Agent:
qwen3-tts-vram· Claude Code session699080d3-3ff0-4337-afa4-94f960590338Assisted-by: Claude Code Ollama Cloud deepseek-v4.1-flash (fully tested and validated)