fix(inventory): preserve distinct PCI devices sharing a serial
This commit is contained in:
1 parent
78e1a473cc
commit
488f730c9d
3 files changed
+74
-5
No files matched your search
@@ -2481,6 +2481,31 @@ device to its real socket. For sources without the map, the fallback can still
|
||||
misplace devices when only the low nodes of a socket carry them (SNC2 with
|
||||
devices on nodes 0 and 1 only: node 1 lands on CPU1).
|
||||
|
||||
## ADL-083 — An equal serial does not merge distinct PCI devices in the UI
|
||||
|
||||
**Date:** 2026-10-19
|
||||
|
||||
**Context:** On G894-SD3-AAX7-000 (B300 NVL8 "Umbriel") all eight onboard
|
||||
ConnectX-8 chips and the ConnectX-7 mezzanine carry the baseboard serial
|
||||
`1951126571627` in PCI VPD. `shouldMergeDevices` treated an equal serial as a
|
||||
hard merge regardless of BDF, so the UI showed one ConnectX-8 while the
|
||||
Reanimator export kept eight (the same gap seen earlier on a G894 sample:
|
||||
5 NICs in the UI, 17 in the export).
|
||||
|
||||
**Decision:** Both copies of the rule — `internal/server/device_repository.go`
|
||||
and parser v27 `normalize` — refuse to merge two devices whose BDFs are both
|
||||
known and differ in bus or device number. Functions of one device
|
||||
(`50:00.0`/`50:00.1`) still merge. Kept devices sharing a serial get the existing
|
||||
`(DUP#n)` annotation; the source serial is not rewritten. Parser dependency
|
||||
moves to v27.
|
||||
|
||||
**Consequences:** UI device counts match the export for chips sharing a carrier
|
||||
serial. A multi-chip card exposing chips on separate buses behind its own switch
|
||||
now shows one row per chip, flagged DUP. The export still sends the shared
|
||||
serial for each chip; per-chip identity (IB node GUID) is left to the easy-bee
|
||||
rewrite in the parser repo.
|
||||
|
||||
|
||||
## ADL-084 — Consume the published Parser v31 release
|
||||
|
||||
**Date:** 2026-10-22
|
||||
|
||||
@@ -462,6 +462,13 @@ func shouldMergeDevices(a, b models.HardwareDevice) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// Distinct PCI devices never merge, even on an equal serial: onboard chips
|
||||
// (B300 NVL8 ConnectX-8) carry their baseboard serial in VPD. Functions of
|
||||
// one device (50:00.0 and 50:00.1) still merge.
|
||||
if aBDF != "" && bBDF != "" && pciDeviceOf(aBDF) != pciDeviceOf(bBDF) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Hard conflicts.
|
||||
if aSN != "" && bSN != "" && aSN == bSN {
|
||||
if a.Kind == models.DeviceKindMemory && b.Kind == models.DeviceKindMemory {
|
||||
@@ -598,6 +605,17 @@ func mergeDevices(primary, secondary models.HardwareDevice) models.HardwareDevic
|
||||
return primary
|
||||
}
|
||||
|
||||
// pciDeviceOf drops the function from a BDF: "0000:50:00.1" -> "0000:50:00".
|
||||
func pciDeviceOf(bdf string) string {
|
||||
if i := strings.LastIndexByte(bdf, '.'); i >= 0 {
|
||||
bdf = bdf[:i]
|
||||
}
|
||||
if strings.Count(bdf, ":") == 1 {
|
||||
bdf = "0000:" + bdf
|
||||
}
|
||||
return bdf
|
||||
}
|
||||
|
||||
func samePCIID(a, b models.HardwareDevice) bool {
|
||||
if (a.VendorID == 0 && a.DeviceID == 0) || (b.VendorID == 0 && b.DeviceID == 0) {
|
||||
return false
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.mchus.pro/reanimator/parser/v31/models"
|
||||
@@ -24,17 +25,17 @@ func TestBuildHardwareDevices_DedupSerialThenBDF(t *testing.T) {
|
||||
}
|
||||
|
||||
devices := BuildHardwareDevices(hw)
|
||||
// 1 board + (SER-1 dedup -> 1) + (BDF 03 dedup -> 1) + (C1,C2 keep both) = 5
|
||||
if len(devices) != 5 {
|
||||
t.Fatalf("expected 5 devices after dedupe, got %d", len(devices))
|
||||
// 1 board + (SER-1 on distinct BDFs keeps both) + (BDF 03 dedup -> 1) + (C1,C2 keep both) = 6
|
||||
if len(devices) != 6 {
|
||||
t.Fatalf("expected 6 devices after dedupe, got %d", len(devices))
|
||||
}
|
||||
|
||||
bySlot := map[string]bool{}
|
||||
for _, d := range devices {
|
||||
bySlot[d.Slot] = true
|
||||
}
|
||||
if !bySlot["A1"] && !bySlot["A2"] {
|
||||
t.Fatalf("expected one serial-deduped A* device")
|
||||
if !bySlot["A1"] || !bySlot["A2"] {
|
||||
t.Fatalf("expected A1 and A2 to stay separate: equal serial, distinct BDFs")
|
||||
}
|
||||
if bySlot["B1"] && bySlot["B2"] {
|
||||
t.Fatalf("expected B1/B2 to dedupe by bdf")
|
||||
@@ -332,3 +333,28 @@ func TestBuildHardwareDevices_CPUUsesPPINAsSerialFallback(t *testing.T) {
|
||||
}
|
||||
t.Fatal("CPU device was not built")
|
||||
}
|
||||
|
||||
func TestBuildHardwareDevices_SharedSerialOnDistinctPCIDevicesIsNotMerged(t *testing.T) {
|
||||
// B300 NVL8: every onboard ConnectX-8 carries the baseboard serial in its
|
||||
// VPD. Functions of one device (50:00.0/.1) still merge; chips on
|
||||
// different buses stay separate and get DUP annotations.
|
||||
hw := &models.HardwareConfig{
|
||||
PCIeDevices: []models.PCIeDevice{
|
||||
{Slot: "0000:0d:00.0", BDF: "0000:0d:00.0", VendorID: 0x15b3, DeviceID: 0x1023, DeviceClass: "NetworkController", PartNumber: "MLX000647", SerialNumber: "1951126571627"},
|
||||
{Slot: "0000:35:00.0", BDF: "0000:35:00.0", VendorID: 0x15b3, DeviceID: 0x1023, DeviceClass: "NetworkController", PartNumber: "MLX000647", SerialNumber: "1951126571627"},
|
||||
{Slot: "0000:50:00.0", BDF: "0000:50:00.0", VendorID: 0x15b3, DeviceID: 0xa2dc, DeviceClass: "EthernetController", SerialNumber: "MT2621606QBJ"},
|
||||
{Slot: "0000:50:00.1", BDF: "0000:50:00.1", VendorID: 0x15b3, DeviceID: 0xa2dc, DeviceClass: "EthernetController", SerialNumber: "MT2621606QBJ"},
|
||||
},
|
||||
}
|
||||
|
||||
var serials []string
|
||||
for _, d := range BuildHardwareDevices(hw) {
|
||||
if d.Kind == models.DeviceKindPCIe || d.Kind == models.DeviceKindNetwork {
|
||||
serials = append(serials, d.BDF+" "+d.SerialNumber)
|
||||
}
|
||||
}
|
||||
want := []string{"0000:0d:00.0 1951126571627 (DUP#1)", "0000:35:00.0 1951126571627 (DUP#2)", "0000:50:00.0 MT2621606QBJ"}
|
||||
if strings.Join(serials, "|") != strings.Join(want, "|") {
|
||||
t.Fatalf("devices = %q, want %q", serials, want)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user