← Back to Pull requests

perf(nfd): publish labels, not raw features, from nfd-worker #3127

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 07, 2026 08:33 UTC
Author

Summary

nfd-worker now publishes node labels instead of raw hardware features (worker.config.core.noPublishFeatures strips everything except kernel.loadedmodule), which shrinks each node's NodeFeature object and the memory nfd-master needs to cache them. The Mellanox NIC label feature.node.kubernetes.io/pci-15b3.present, which a cluster-side rule used to compute from the stripped pci.device feature, is now also computed by an nfd-worker rule in every recipe that ships network-operator.

Motivation / Context

On a 1720-node GB300 cluster, nfd-master cached about 334 KB of raw features per node, mostly kernel.config, and was OOMKilled every 2.5 minutes at the 4Gi chart default (#3038). #3046 raises the limit to 8Gi, but memory still scales with node count times object size. This change shrinks the objects instead. It ports the approach of GitLab ngn/n2-helm/nfd MR 28, which cut nfd-master memory by about 50% on GFN's 750-host data centers.

Fixes: N/A
Related: #3038
Related: #3046

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

  • New feature (non-breaking change that adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

  • Documentation update

  • Refactoring (no functional changes)

  • Build/CI/tooling
  • Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)

  • API server (cmd/aicrd, pkg/server)

  • Recipe engine / data (pkg/recipe)

  • Bundler and deployers (pkg/bundler, pkg/component)

  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)

  • Validator (pkg/validator)

  • Core libraries (pkg/errors, pkg/k8s)

  • Docs/examples (docs/, examples/)

  • Other: recipes/components/nfd, recipes/components/network-operator, overlays that add network-operator
  • Implementation Notes

  • What is stripped. nfd-worker still discovers every feature and computes every label, including its own sources.custom rules, from the full set; noPublishFeatures only drops keys from the NodeFeature it writes (NFD v0.19.0, the current pin; no chart bump). Only cluster-side NodeFeatureRule and NodeFeatureGroup objects read published features. kernel.loadedmodule stays published for the GPU Operator's opt-in nvidia-kernel-modules rule.

  • Who read stripped features. All 35 registry charts were pulled at their pins and grepped for NodeFeatureRule/NodeFeatureGroup. The only enabled consumers were network-operator's nvidia-nics-rules and AICR's AKS nfd-network-rule.yaml, both reading pci.device to set pci-15b3.present.

  • The worker-side NIC rule (components/nfd/values-nvidia-nics.yaml; values-nvidia-nics-aks.yaml matches only the ND-series InfiniBand VFs 101c/101e) is wired only into overlays that ship network-operator. On a recipe without network-operator the label would make the GPU Operator validator wait for a MOFED driver nothing installs (GPUDirect RDMA on, useHostMofed false).

  • Expand/contract. This release keeps both cluster-side rules. Deleting them in the same release raced the nfd-worker rollout on Argo CD, deploy.sh --no-wait and Helm 3: nodes whose worker had not restarted lost the label, and the NicClusterPolicy operands and the AKS peermem reloader were deleted on them. With the rules kept, a node's worker write that drops pci.device also adds the label, so the handoff has no gap whatever the deployer order. Once workers strip pci., the old rules match nothing. A follow-up removes them in the next release; clusters should take this release first.

  • Flux on AKS (not new). The Flux bundle keeps the AKS nfd-network-rule manifest as a Helm hook (before-hook-creation), so each network-operator-post upgrade deletes and recreates it, and a node whose worker has not restarted can lose the label for about a second. Flux already recreates the AKS NicClusterPolicy the same way on every upgrade. This PR narrows that window to the nodes whose worker has not restarted; making network-operator-post wait for nfd, or dropping the hook, is a deployer change left out of scope.

  • Guard. TestNFDFeaturePublishingContract resolves every leaf and checks, on merged values:

  • - exactly one worker NIC rule with the right vendor and class (or, on AKS, device) values when network-operator ships, and none otherwise, including through sources.pci or a labelsTemplate rule;
    - no rendered NodeFeatureRule or NodeFeatureGroup (chart-shipped, or a manifest parsed as YAML) reads a stripped feature, except the two transitional NIC rules, which are required on every network-operator leaf in this release and must be deleted together with the allowlist in the follow-up;
    - the effective strip list, including worker.extraArgs overrides (-no-publish-features, -options, -no-publish), equals the expected list on every nfd leaf;
    - nothing (labelSources, featureSources, core.sources, extraArgs) stops the worker rule from running.

    Each helper that replays NFD v0.19.0 semantics has its own table test.

  • Bundle-time warning. aicr bundle warns when network-operator and the nfd NIC rule disagree on the final values: network-operator ships while nfd strips pci.device and has no worker rule for pci-15b3.present (a custom overlay that adds network-operator without the nfd values file), or nfd carries the rule without network-operator (--set networkoperator:enabled=false without the --set-json). bundlers= subsets stay silent. It is a warning, not an error, because the check does not replay worker.extraArgs or labelsTemplate rules.

  • Overrides (documented in docs/user/component-catalog.md, each verified by rendering a bundle): publish features again for your own NodeFeatureRules with --set-json 'nfd:worker.config.core.noPublishFeatures=[...]'; sources.custom is a list, so overriding it replaces the NIC rule; the AKS RDMA opt-out now also needs --set-json 'nfd:worker.config.sources.custom=[]'.

  • Out of scope: OpenShift (nfd-ocp), nfd-master resource limits (#3046).

  • Known limits of the guard (no shipped file hits them): config keys spelled in another case (NFD matches them case-insensitively), -options setting sources., a template that writes a literal pci-15b3.present, and template lines that render rule content.
  • Testing

    make qualify
    

    Green at the PR head (88d28a370), run as its two halves on the same SHA because load from other jobs on the machine timed out unrelated timing tests in single runs (each passed alone):

  • make test-coverage coverage-check: rc=0, total coverage 85.3% (threshold 83%).

  • make lint tuning-check e2e scan license-check api-diff openapi-diff: rc=0; golangci-lint 0 issues; chainsaw 30 passed, 0 failed; scan lists only the existing low/unknown findings in k8s.io/kubernetes and golang.org/x/crypto; no incompatible SDK or REST contract changes.

  • make bom-docs: no change for nfd or network-operator.
  • Guard: go test -count=1 -run '^TestNFD' -v ./pkg/recipe/ at the PR head passes 286 checks across 9 test functions, including all 133 leaves. Mutation checks, each run with go test -overlay so the tree is untouched, turn it red:

  • - dropping an AKS leaf's NIC values file;
    - adding the NIC rule to a recipe without network-operator;
    - turning the transitional chart rule off (13 leaves) or dropping the AKS manifest (14);
    - enabling a non-transitional rule that reads pci.device;
    - deleting or narrowing the strip list, or overriding it through extraArgs (129 each);
    - a sources.pci producer (129) or a labelsTemplate producer (102);
    - narrowing labelSources or featureSources (27);
    - a manifest feature: line with a trailing comment (14).

    The same mutants pass against the test before each fix.

  • kind, NFD 0.19.0 (virtio-net vendor 1af4 standing in for 15b3): NodeFeature spec 64,709 bytes before, 2,979 after; only kernel.loadedmodule still published; node labels unchanged apart from a control rule that reads kernel.config.

  • 3-worker kind upgrade race, with a stand-in DaemonSet using the NicClusterPolicy node affinity: deleting the cluster-side rule right after a no-wait nfd upgrade dropped the label in 39 of 104 half-second samples and deleted 3 pods. With the rule kept (this PR): 0 of 114. Two worker restarts mid-upgrade: 0 of 116. Deleting the rule after every worker rolled (the follow-up): 0 of 70.

  • Coverage: pkg/recipe 90.7% -> 90.7% (0.0%); the only non-test Go change is one comment in pkg/recipe/metadata.go.

  • Review round: make qualify at f878111 (same content as a363eb9 before the rebase onto d37ce8f), run as two halves. make lint tuning-check e2e scan license-check api-diff openapi-diff: rc=0, golangci-lint 0 issues, chainsaw 30 passed, 0 failed. make test-coverage: every package passed except TestApplyCRDsScript_BoundsStalledApply in pkg/bundler/deployer/localformat, which this PR does not touch; its 2s helm list bound timed out under host load, and it passes alone (go test -race -run TestApplyCRDsScript ./pkg/bundler/deployer/localformat/). At a363eb9, the NFD guard, golden and warning tests pass. The warning has 13 table rows plus both of Mark's paths through Make(), and each guard's mutant turns a row red. Coverage: pkg/bundler 87.4% -> 87.5%, pkg/recipe 90.7% -> 90.7%.
  • Risk Assessment

  • Low — Isolated change, well-tested, easy to revert

  • Medium — Touches multiple components or has broader impact

  • High — Breaking change, affects critical paths, or complex rollout
  • Every recipe that deploys nfd changes what nfd-worker publishes. A user-authored NodeFeatureRule that matches a stripped feature stops matching until that feature is published again (documented override). The NIC label handoff is covered by the guard and the kind runs above. Production nfd-master memory has not been measured yet on the 1720-node cluster.

    Rollout notes: No migration step. This release keeps network-operator's nvidia-nics-rules and the AKS nfd-network-rule, so the NIC label stays on every node during the upgrade (Flux on AKS: see Implementation Notes). The next release removes them, so clusters should take this release before that one, or let the nfd-worker rollout finish before network-operator syncs.

    Checklist

  • Tests pass locally (make test with -race)

  • Linter passes (make lint)

  • I did not skip/disable tests to make CI green

  • I added/updated tests for new functionality

  • I updated docs if user-facing behavior changed

  • Changes follow existing patterns in the codebase

  • Commits are signed off and cryptographically signed (git commit -s -S)
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: ArangoGutierrez Review duration: 701m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3127"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%
    Repository