Skip to content

feat(node-agent): Node Agent CDI Simulator - #728

Merged
roma-glushko merged 7 commits into
mainfrom
node-agent-mvp-cdi
Aug 26, 2026
Merged

feat(node-agent): Node Agent CDI Simulator#728
roma-glushko merged 7 commits into
mainfrom
node-agent-mvp-cdi

Conversation

@roma-glushko

@roma-glushko roma-glushko commented Aug 25, 2026

Copy link
Copy Markdown
Member

What This PR Does

Ported the CDI logic as a new node agent Simulator.
Cleaned up nvml-mock scripts from ported logic.

Why

A part of MEP0003.

Checklist

  • Commits are signed off (git commit -s)
  • Tests pass (go test -v -race ./...)
  • Linter passes (make lint-fix)
  • New code has SPDX license headers
  • Documentation updated (if applicable)
  • CHANGELOG.md updated (if user-facing change)

Stack created with GitHub Stacks CLIGive Feedback 💬

@roma-glushko roma-glushko self-assigned this Aug 25, 2026
@roma-glushko roma-glushko added the kind/feature Feature request or enhancement. label Aug 25, 2026
giuliocalzo
giuliocalzo previously approved these changes Aug 25, 2026
faganihajizada
faganihajizada previously approved these changes Aug 25, 2026
@giuliocalzo

Copy link
Copy Markdown
Collaborator

Non-blocking suggestion: consider giving the CDI simulator a logger and emitting one line per Apply, the way I ended up doing it for rdmaplugin in #734.

The reasoning is the same for both. agent.reconcile logs only failures, so a simulator that succeeds is invisible, and FileSource emits an update on subscribe and then only when the config hash changes — so Apply runs once at startup and then rarely. One Info per Apply is therefore bounded, and it's the only evidence the surface was actually published.

That matters more for CDI than for most surfaces: when the spec is missing or stale, the symptom shows up far away, as containerd refusing container creation or injecting nothing, and the first question is whether the agent wrote the spec at all and with how many devices.

Something like:

func New(log *slog.Logger) *Simulator { return &Simulator{log: log} }

func (s *Simulator) Apply(_ context.Context, h *host.Host, state *agent.State) error {
    nvidiaPath := filepath.Join(h.Run, nvidiaSpecFile)
    nriPath := filepath.Join(h.Run, nriSpecFile)
    if err := writeSpec(h, nvidiaPath, buildNvidiaSpec(state)); err != nil {
        return fmt.Errorf("nvidia.yaml: %w", err)
    }
    if err := writeSpec(h, nriPath, buildNRISpec(state)); err != nil {
        return fmt.Errorf("nvml-mock-nri.yaml: %w", err)
    }
    s.log.Info("wrote CDI specs", "simulator", name,
        "nvidia", nvidiaPath, "nri", nriPath, "devices", len(state.Devices))
    return nil
}

rdmaplugin also carries a patched field to distinguish a real write from a no-op, but that only exists because it reads the node before patching. host.WriteFile rewrites unconditionally, so there's no equivalent here and I wouldn't add change detection just for the log line.

Happy to fold this into #734 instead if you'd rather keep this PR as a straight port.

Signed-off-by: Roman Hlushko <rhlushko@nvidia.com>

# Conflicts:
#	deployments/nvml-mock/helm/nvml-mock/templates/daemonset.yaml
Signed-off-by: Roman Hlushko <rhlushko@nvidia.com>
Signed-off-by: Roman Hlushko <rhlushko@nvidia.com>
Signed-off-by: Roman Hlushko <rhlushko@nvidia.com>
Signed-off-by: Roman Hlushko <rhlushko@nvidia.com>
Signed-off-by: Roman Hlushko <rhlushko@nvidia.com>
Signed-off-by: Roman Hlushko <rhlushko@nvidia.com>
@roma-glushko
roma-glushko deleted the branch main August 26, 2026 11:29
@roma-glushko roma-glushko reopened this Aug 26, 2026
@roma-glushko
roma-glushko changed the base branch from node-agent-mvp-v2 to main August 26, 2026 11:32
@roma-glushko
roma-glushko dismissed stale reviews from faganihajizada and giuliocalzo August 26, 2026 11:32

The base branch was changed.

@ArangoGutierrez ArangoGutierrez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@roma-glushko
roma-glushko merged commit a2f083f into main Aug 26, 2026
51 of 63 checks passed
@roma-glushko roma-glushko linked an issue Aug 26, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Feature request or enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MEP0003: Implement Node Agent

4 participants