Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/api-model/src/site_explorer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,28 @@ impl ExploredEndpoint {
}

impl EndpointExplorationReport {
/// The boot interface MAC for this endpoint's explored default -- the boot
/// interface site-explorer records before any machine owns the endpoint.
///
/// A declared `ExpectedHostNic.primary` wins when this report has that NIC,
/// whatever its type (an integrated NIC as readily as a DPU host-PF), so the
/// explored default agrees with the managed store's declared primary across
/// the ownership handoff. Absent a declaration, it falls back to the
/// automatic pick: the lowest-PCI DPU host-PF interface.
pub fn fetch_host_primary_interface_mac(
&self,
explored_dpus: &[ExploredDpu],
declared_primary: Option<MacAddress>,
) -> Option<MacAddress> {
// A declared primary wins as long as the report has it as a full pair
// (`find_interface_id_for_mac` scans every system ethernet interface,
// integrated NICs included).
if let Some(declared) = declared_primary
&& self.find_interface_id_for_mac(declared).is_some()
{
return Some(declared);
}

let system = self.systems.first()?;

// Gather explored DPUs mac.
Expand Down
8 changes: 7 additions & 1 deletion crates/site-explorer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,9 +1323,15 @@ impl SiteExplorer {
// If we know the booting interface of the host, we should use this for deciding
// primary interface.
let mut is_sorted = false;
// A declared `ExpectedHostNic.primary` (when the matched expected
// machine sets one) wins over the automatic DPU-PF pick, so the
// explored default names the same NIC the managed store will.
let declared_primary = expected_explored_endpoint_index
.matched_expected_machine(&ep.address)
.and_then(|expected| expected.data.declared_primary_mac());
if let Some(mac_address) = ep
.report
.fetch_host_primary_interface_mac(&dpus_explored_for_host)
.fetch_host_primary_interface_mac(&dpus_explored_for_host, declared_primary)
{
// Capture the boot interface's [stable] Redfish interface id
// alongside its MAC. Only persist when both resolve from the
Expand Down
46 changes: 45 additions & 1 deletion crates/site-explorer/tests/site_explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2252,11 +2252,55 @@ async fn test_fetch_host_primary_interface_mac(
});
}

// No declaration: the automatic pick stands -- the lowest-PCI DPU host-PF
// (the second mock DPU, given the device paths set above).
let expected_mac: MacAddress = mock_dpus[1].host_mac_address;
let mac = host_report
.fetch_host_primary_interface_mac(&explored_dpus)
.fetch_host_primary_interface_mac(&explored_dpus, None)
.unwrap();
assert_eq!(mac, expected_mac);

// A declared primary on a DPU host-PF wins over the automatic pick -- here
// the first DPU, which the PCI ordering would NOT have chosen.
let declared_dpu_pf = mock_dpus[0].host_mac_address;
assert_eq!(
host_report
.fetch_host_primary_interface_mac(&explored_dpus, Some(declared_dpu_pf))
.unwrap(),
declared_dpu_pf,
);

// The headline case: a declared *integrated* NIC -- which the DPU-only
// automatic pick can never name -- becomes the explored default.
let integrated_nic = host_report
.systems
.first()
.unwrap()
.ethernet_interfaces
.iter()
.filter_map(|e| e.mac_address)
.find(|mac| {
!explored_dpus
.iter()
.any(|d| d.host_pf_mac_address == Some(*mac))
})
.expect("the fixture host should have a non-DPU integrated NIC");
assert_eq!(
host_report
.fetch_host_primary_interface_mac(&explored_dpus, Some(integrated_nic))
.unwrap(),
integrated_nic,
);

// A declared MAC absent from this report is ignored -- the automatic pick
// stands.
let absent_mac: MacAddress = "de:ad:be:ef:00:01".parse().unwrap();
assert_eq!(
host_report
.fetch_host_primary_interface_mac(&explored_dpus, Some(absent_mac))
.unwrap(),
expected_mac,
);
Ok(())
}

Expand Down
Loading