Skip to content

fix(quadlet): emit the CDI device once when security.devices repeats it - #645

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/quadlet-dedupe-cdi
Nov 25, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/quadlet-dedupe-cdi

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A GPU unit whose caller also lists nvidia.com/gpu=all in security.devices got the CDI device line
twice: emitContainerSecurity writes the implicit line for every GPU unit, then writes every
Security.Devices entry 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 and
skipped in the explicit list when it would repeat it. Non-CDI entries (/dev/dri/renderD128, …) are
unchanged, and the privileged branch is untouched (a privileged unit never carries the CDI device).

 deploykit/quadlet.go      | 12 +++++++++++-
 deploykit/quadlet_test.go | 17 +++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

How tested

The regression test is the spike-equivalent (R12): it fails on the unmodified emitter and passes
with the fix.

Red — dedupe removed, CDIDevice kept so the tree compiles:

$ go test ./deploykit/ -run TestGenerateQuadletCDIDeviceIsEmittedOnce -count=1
--- FAIL: TestGenerateQuadletCDIDeviceIsEmittedOnce (0.00s)
    quadlet_test.go:933: CDI device emitted 2 times, want exactly 1
        AddDevice=nvidia.com/gpu=all
FAIL

Green — the fix in place, and the whole package plus vet:

$ go test ./deploykit/ -count=1
ok  	github.com/opencharly/sdk/deploykit	15.069s
$ go vet ./deploykit/
vet-exit=0

The neighbouring unit that pins the GPU shape is unchanged and passes:
TestGenerateQuadletPodmanArgsAndReadOnlyBind (it asserts PodmanArgs=--cdi-spec-dir …,
Volume=…/libcuda.so.1:ro, AddDevice=nvidia.com/gpu=all, UserNS=keep-id:…).

Rulebook compliance

  • R0: /charly-internals:install-plan and /charly-internals:go were loaded; this is the
    sdk's quadlet emitter, the deploy-mode target's own code.
  • R1: the finding is filed as quadlet emitter writes AddDevice=nvidia.com/gpu=all twice when security.devices already lists it #643 and fixed in this change; the mechanism is in
    the code (implicit line + explicit list), not a guess.
  • R2: this change REMOVES a duplication rather than adding one — one constant, one emission.
  • R3: no workaround; the second emission is gone, not hidden.
  • R4: no documented command changes.
  • R5: nothing legacy left; the implicit line now uses the constant too.
  • R6: git status was clean before the commit.
  • R7: the behaviour is proven by a test that fails without the change (red pasted above) and
    the full package plus vet pass on the final tree.
  • R8: N/A — no live-service boundary.
  • R9: N/A — no binary artifact in this module's change class.
  • R10: the module's gate is go test ./deploykit/ + go vet, run above; no disposable target is
    involved in a library emitter change.
  • R11: no DESIGN field, shape, kind, verb or capability touched; cdiDevice is an UNEXPORTED
    package constant — not a wire type and not part of the sdk's public API. (Round 2: the first
    revision exported it as CDIDevice while the body called it internal; the code was the wrong
    half, so it is unexported now.)
  • R12: the spike-equivalent applies and is pasted under ## How tested — the regression test
    fails on the unmodified tree (CDI device emitted 2 times, want exactly 1) and passes with the fix.

Change classification

  • Type: fix (deploy-emitter duplication).
  • Breaking change + rollback: none — a unit that previously carried the line twice carries it
    once; podman treated both identically. Rollback is reverting the commit.

Filed issues

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)

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)*
@github-actions

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 2baa87cb9e95ad8f31b0b7e35241c6adf07bd417 (branch: fix/quadlet-dedupe-cdi)

Change class: code (sdk deploykit library — quadlet emitter).

Blocks

  1. A1 / R11 / T3 — body contradicts the code on CDIDevice's visibility. The body states
    "CDIDevice is an internal constant, not a wire type" (R11) and describes it as "one spelling"
    used internally. The diff declares it exported:
    deploykit/quadlet.go → const CDIDevice = "nvidia.com/gpu=all" (capital → public API of the
    sdk). Nothing in the diff or body consumes it outside the package, so the export is
    unjustified, and the "internal constant" claim is factually false — a description↔code
    mismatch. In a public sdk, exporting the constant silently makes the CDI device string part of
    the semver contract (changing it later becomes a breaking API change), while the body claims
    it is merely internal. Fix one of:
    • Unexport it to cdiDevice so the code matches the "internal constant" claim (this still
      works from the test if quadlet_test.go is package deploykit), or
    • Correct the body (R11) to acknowledge the new exported public API and state why it must
      be public.

The fix logic itself is correct (implicit line and explicit-list dedupe both keyed on
carriesCDIDevice, so privileged/non-GPU callers that list the CDI device still emit it exactly
once via the explicit list; non-CDI entries are untouched), and the red/green regression evidence
is internally consistent (quadlet_test.go:933 matches the pasted failure line). This single
visibility/description inconsistency is the only block.

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

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)*
@github-actions

Copy link
Copy Markdown

Review — PASS

Head SHA: f4d93c4833b59e5bd6318738df6e87dd2549c996 (branch: fix/quadlet-dedupe-cdi)

Security screen: PASS
Checklist: All applicable rules PASS or NA (code-only sdk library change; unexported cdiDevice, dedupe keyed on carriesCDIDevice so privileged/non-GPU callers still emit via the explicit list; red/green evidence internally consistent — quadlet_test.go:933 matches the pasted failure line; Agent: then Assisted-by: footer order correct; ## Filed issues names sdk#643).
Comment 7166571466 (@github-actions[bot]) — stale-superseded: it blocked on an exported CDIDevice; the current diff declares unexported const cdiDevice and the body's R11 note now says so.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 25, 2026 15:24
@github-actions
github-actions Bot merged commit 4f60605 into main Nov 25, 2026
8 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant