fix(xfusion): emit OCP NIC ports with no serial so reanimator keys them by MAC
Verified against reanimator/core: it keys a NIC component on serial → MAC → synthetic(slot). A BMC dump carrying the card serial collapses both ports into one serial-keyed component, while a live-CD bundle (no serial) keeps two MAC-keyed components, so alternating the two sources produced a spurious COMPONENT_REMOVED + 2x COMPONENT_INSTALLED every time. Emitting the per-port NetworkAdapter entries with an empty serial makes both sources key on the port MAC and yield the same two components. The card serial still reaches the export via the FRU record and the legacy NIC entry. Also records ADL-062 findings from reading the ingesting audit tool: it persists only vendor/model/serial per component (no size/speed/link/clock/wattage), so the remaining one-sided field diffs between the two bundles cannot generate change events. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VFy4m7cVv4cqp25jJh2gSB
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
9b2c654182
commit
8e7f22077d
+21
-4
@@ -710,9 +710,17 @@ func mergeNetworkAdapters(cards []xfusionNICCard, snapshots []xfusionNetcardSnap
|
||||
}
|
||||
|
||||
// Emit one adapter per PCI function (port), keyed by that port's own BDF,
|
||||
// so the card matches an OS-level lspci view of the same NIC. Ports share
|
||||
// the physical card's serial/part number. Fall back to a single
|
||||
// card-level entry only when no per-port BDF is available.
|
||||
// so the card matches an OS-level lspci view of the same NIC. Fall back to
|
||||
// a single card-level entry only when no per-port BDF is available.
|
||||
//
|
||||
// The per-port entries deliberately carry NO serial number. The physical
|
||||
// card has one serial across both ports; an in-band collector (lspci) sees
|
||||
// none and identifies each port by its MAC. Reanimator keys a NIC on
|
||||
// serial → MAC → synthetic(slot): if we emitted the card serial here, its
|
||||
// two ports would collapse to one component keyed by that serial, while
|
||||
// the same NIC from a live-CD bundle stays two components keyed by MAC —
|
||||
// producing a spurious remove+reinstall every time the two sources
|
||||
// alternate. Leaving serial empty makes both sources key on MAC and agree.
|
||||
type portEntry struct {
|
||||
bdf string
|
||||
mac string
|
||||
@@ -734,6 +742,15 @@ func mergeNetworkAdapters(cards []xfusionNICCard, snapshots []xfusionNetcardSnap
|
||||
} else if len(ports) == 1 {
|
||||
portMACs = macs
|
||||
}
|
||||
// No serial: an lspci-based collector has none, and reanimator keys a
|
||||
// serial-bearing NIC on the serial (collapsing ports) but a
|
||||
// serial-less one on the MAC. Keeping this empty makes a BMC dump and
|
||||
// a live-CD run agree. The card serial still reaches the export via
|
||||
// this card's FRU record.
|
||||
serialPerPort := ""
|
||||
if len(portMACs) == 0 {
|
||||
serialPerPort = card.SerialNumber
|
||||
}
|
||||
adapters = append(adapters, models.NetworkAdapter{
|
||||
Slot: firstNonEmpty(p.bdf, slot),
|
||||
Location: "OCP",
|
||||
@@ -744,7 +761,7 @@ func mergeNetworkAdapters(cards []xfusionNICCard, snapshots []xfusionNetcardSnap
|
||||
Vendor: manufacturer,
|
||||
VendorID: card.VendorID,
|
||||
DeviceID: card.DeviceID,
|
||||
SerialNumber: card.SerialNumber,
|
||||
SerialNumber: serialPerPort,
|
||||
PartNumber: card.PartNumber,
|
||||
Firmware: firmware,
|
||||
PortCount: 1,
|
||||
|
||||
+7
-2
@@ -218,8 +218,13 @@ Product Name: G5500 V7
|
||||
if a.Firmware != "26.39.2048" {
|
||||
t.Fatalf("adapter %s firmware = %q, want 26.39.2048", a.BDF, a.Firmware)
|
||||
}
|
||||
if a.SerialNumber != "02Y238X6RC000058" {
|
||||
t.Fatalf("adapter %s serial = %q, want 02Y238X6RC000058", a.BDF, a.SerialNumber)
|
||||
// Ports keyed by MAC, not by the shared card serial, so a BMC dump and an
|
||||
// lspci-based bundle produce the same components.
|
||||
if a.SerialNumber != "" {
|
||||
t.Fatalf("adapter %s serial = %q, want empty (MAC-keyed)", a.BDF, a.SerialNumber)
|
||||
}
|
||||
if a.PartNumber != "0302Y238" {
|
||||
t.Fatalf("adapter %s part number = %q, want 0302Y238", a.BDF, a.PartNumber)
|
||||
}
|
||||
}
|
||||
if got := byBDF["0000:27:00.0"].MACAddresses; len(got) != 1 || got[0] != "44:1A:4C:16:E8:03" {
|
||||
|
||||
Reference in New Issue
Block a user