DRA: publish PCIe roots on topology-aware devices #831
<!-- ccr-overview-v2 -->
🟢 Approval recommended
Discovery, compatibility probing, publication, and slice sizing are consistently implemented and well tested.
0 open findings
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds PCIe-root topology attributes to topology-aware DRA devices while remaining compatible with clusters lacking list-attribute support.
Changes:
| File | Description |
| ---- | ----------- |
| pkg/sysfs/system.go | Discovers package-local PCIe roots. |
| pkg/sysfs/pcie_test.go | Tests PCIe-root discovery edge cases. |
| pkg/sysfs/system_test.go | Verifies recorded root topology. |
| pkg/sysfs/test-setup.sh | Extracts the new sample. |
| pkg/sysfs/test-data-sample3.tar.xz | Provides recorded SNC topology. |
| pkg/resmgr/dra/plugin.go | Probes list support and limits slice size. |
| pkg/resmgr/dra/plugin_test.go | Tests probing and slice splitting. |
| pkg/resmgr/dra.go | Exposes probe results to policies. |
| pkg/resmgr/policy/policy.go | Extends the policy-owner contract. |
| cmd/plugins/topology-aware/policy/dra.go | Publishes PCIe-root attributes. |
| cmd/plugins/topology-aware/policy/dra_test.go | Tests conditional root publication. |
| cmd/plugins/topology-aware/policy/mocks_test.go | Updates package mocks. |
| cmd/plugins/topology-aware/policy/coldstart_test.go | Updates the test owner interface. |
| test/e2e/policies.test-suite/topology-aware/n4c16/test43-dra-pcie-roots/code.var.sh | Verifies cluster-level publication behavior. |
</details>
🧠 Review effort: Balanced
---
💡 <a href="/containers/nri-plugins/new/stacked/bart0sh/DRA/008-resmgr-refresh-node-resources?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
LGTM
LGTM
klihub
bart0sh
Publishing PCIe roots on topology-aware DRA devices
Ninth PR of the DRA series, on top of #829. Four commits.
Each topology-aware DRA device now has the standard
resource.kubernetes.io/pcieRootattribute: the PCIe roots of the device's CPU socket. With it, a claim can usematchAttributeto get CPUs and a device of another driver, such as a NIC, under the same PCIe root.Which roots a device lists
The kernel reports the CPUs local to a PCIe root in
/sys/devices/pciDDDD:BB/pci_bus/DDDD:BB/cpulistaffinity. It computes them from the NUMA node of the root. With sub-NUMA clustering, this is one zone of the socket, but the root is equally close to all zones of the socket. So sysfs discovery gives a root to every package that its local CPUs are in. Every NUMA device of a package lists all the roots of that package.For example, on a two-socket machine with SNC2, so four NUMA nodes, root
pci0000:5dreports only the CPUs of node 2. Nodes 0 and 2 both listpci0000:00,pci0000:17,pci0000:3aandpci0000:5d.CPUPackage.PCIeRoots()returns the roots of a package, sorted. A root whosecpulistaffinitycannot be read is skipped.Clusters without list attributes
pcieRootis a list attribute. List attributes need theDRAListTypeAttributesfeature gate (KEP-5491), which is alpha and off by default. Without the gate, the API server rejects the whole ResourceSlice, so no devices would be published at all.A driver cannot read the gate, so the DRA plugin asks the API server. When the plugin is created, it does a server-side dry run of a slice with a list attribute. Any failure counts as no support. Policies get the result from
Owner.DRAListAttributesSupported(), and topology-aware leavespcieRootout without support. The driver itself still does not look at device attributes.A slice with list attributes holds at most 64 devices, not 128. The plugin now always splits the devices into slices of 64.
What is not here
DeviceClassships yet, as in the earlier PRs of the series.Verification
go test -racepasses for sysfs, resmgr, the DRA plugin and the template, balloons and topology-aware policies, and golangci-lint finds no issues.TestRecordedPCIeRootschecks the roots of each package in the recorded sample.TestDiscoverPCIeRootsalso covers a root reporting CPUs of both sockets, a root in no package, and roots that cannot be read.TestProbeListAttributescovers an accepted, a rejected and a failed probe, and checks that the probe is a dry run.TestDRAPCIeRootschecks that no roots are published without support, and that the roots of package 0 appear on its two NUMA nodes once there is support.test43-dra-pcie-rootsandtest42-dra-devicespass on n4c16 with Kubernetes 1.37 and containerd v2.4.1, with and withoutDRAListTypeAttributes. With the gate, every device lists the only root of the VM,pci0000:00. Without it, the devices are published withoutpcieRoot.