Skip to content

quadlet emitter writes AddDevice=nvidia.com/gpu=all twice when security.devices already lists it #643

Done

Description

@aitrawog

Category

category:delivery

Type

type:fix

Remedy / files the remedy will touch

sdk/deploykit/quadlet.go emitContainerSecurity (dedupe the implicit CDI line against Security.Devices)

Cited design decision or org-rulebook rule (or none)

AGENTS.md R2

A generated quadlet can carry the CDI device line twice. Observed on this host in
~/.config/containers/systemd/charly-ollama-cdi.container (generated 2026-11-24 12:09):

$ grep -n 'AddDevice' ~/.config/containers/systemd/charly-ollama-cdi.container
16:AddDevice=nvidia.com/gpu=all
17:AddDevice=nvidia.com/gpu=all
18:AddDevice=/dev/dri/renderD128
19:AddDevice=/dev/dri/renderD129
20:AddDevice=/dev/kfd

Mechanism, from the emitter: emitContainerSecurity writes the implicit line when
carriesCDIDevice(cfg) is true (sdk/deploykit/quadlet.go:276) and then unconditionally loops
cfg.Security.Devices writing every entry (:287) — so when the merged Security.Devices list already
contains nvidia.com/gpu=all (a box/candy declaring the device explicitly, merged by
sdk/deploykit/security.go), the same directive is emitted twice.

Podman tolerates the duplicate, so this is not a functional break — but it is two sources of truth for
one directive, and it hides which one owns it: a future change that stops emitting the implicit line
would look like it removed the device when the explicit list still carries it.

Remedy: dedupe on the emitted value — skip a Security.Devices entry equal to the implicit CDI device
when carriesCDIDevice(cfg), or emit the union once.

Agent: qwen3-tts-vram · Claude Code session 699080d3-3ff0-4337-afa4-94f960590338
Assisted-by: Claude Code deepseek-v4.1-flash (analysed on a live system)

Activity

  1. added
    category:delivery
    type:fix
    on Nov 25, 2026
  2. aitrawog commented on Nov 25, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED

    Fixed by #645 (merged): emitContainerSecurity now uses one unexported constant (cdiDevice) for the implicit line and skips a Security.Devices entry that repeats it, so a GPU unit whose caller also lists nvidia.com/gpu=all emits AddDevice exactly once. Non-CDI device entries are unchanged, and the privileged branch is untouched. A regression test fails on the unmodified emitter (CDI device emitted 2 times, want exactly 1) and passes with the fix.

    Agent: qwen3-tts-vram · Claude Code session 699080d3-3ff0-4337-afa4-94f960590338
    Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)

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

    category:deliverytype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions