Skip to content
Open
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
6 changes: 4 additions & 2 deletions crates/health/example/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ port = 443
mac = "11:22:33:44:55:66"
username = "admin"
password = "secret"
switch = { id = "fsw100htjtiaehv1n5vh67tbmqq4eabcjdng40f7jupsadbedhruh6rag1l0", serial = "SN-SWITCH-BMC-001", endpoint_role = "bmc", slot_number = 7, tray_index = 3 }
# Configure the same domain UUID on every static endpoint for the switch.
# Invalid or nil values are omitted from telemetry.
switch = { id = "fsw100htjtiaehv1n5vh67tbmqq4eabcjdng40f7jupsadbedhruh6rag1l0", serial = "SN-SWITCH-BMC-001", endpoint_role = "bmc", slot_number = 7, tray_index = 3, nvlink_domain_uuid = "9f4b45ec-705a-4af4-89f7-a112bc9c8f4e" }

[[endpoint_sources.static_bmc_endpoints]]
ip = "10.0.1.2"
Expand All @@ -60,7 +62,7 @@ password = "secret"
# For static switch host endpoints, nmxc_enabled controls direct NMX-C
# Subscribe eligibility after the endpoint_role="host" and is_primary=true
# checks. If omitted, it defaults to is_primary.
switch = { id = "fsw100htjtiaehv1n5vh67tbmqq4eabcjdng40f7jupsadbedhruh6rag1l0", serial = "SN-SWITCH-HOST-001", endpoint_role = "host", is_primary = true, nmxc_enabled = true, slot_number = 7, tray_index = 3 }
switch = { id = "fsw100htjtiaehv1n5vh67tbmqq4eabcjdng40f7jupsadbedhruh6rag1l0", serial = "SN-SWITCH-HOST-001", endpoint_role = "host", is_primary = true, nmxc_enabled = true, slot_number = 7, tray_index = 3, nvlink_domain_uuid = "9f4b45ec-705a-4af4-89f7-a112bc9c8f4e" }

[[endpoint_sources.static_bmc_endpoints]]
ip = "10.0.2.1"
Expand Down
54 changes: 53 additions & 1 deletion crates/health/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use std::net::IpAddr;
use std::str::FromStr;
use std::sync::{Arc, Mutex};

use carbide_uuid::nvlink::NvLinkDomainId;
use carbide_uuid::rack::RackId;
use carbide_uuid::switch::SwitchId;
use forge_tls::client_config::ClientCert;
Expand Down Expand Up @@ -275,6 +276,9 @@ fn switch_endpoint_metadata(
.placement_in_rack
.as_ref()
.and_then(|placement| placement.tray_index),
nvlink_domain_uuid: switch
.nvlink_domain_uuid
.filter(|domain_uuid| domain_uuid != &NvLinkDomainId::nil()),
endpoint_role,
is_primary: switch.is_primary,
nmxc_enabled: config.enable_nmxc,
Expand Down Expand Up @@ -755,7 +759,8 @@ impl From<rpc::forge::bmc_credentials::Type> for BmcCredentials {
mod tests {
use std::sync::atomic::{AtomicUsize, Ordering};

use carbide_test_support::value_scenarios;
use carbide_test_support::{Check, check_values, value_scenarios};
use carbide_uuid::nvlink::NvLinkDomainId;
use carbide_uuid::switch::{SwitchId, SwitchIdSource, SwitchType};
use nv_redfish::bmc_http::reqwest::ClientParams as ReqwestClientParams;

Expand Down Expand Up @@ -847,6 +852,53 @@ mod tests {
);
}

#[test]
fn switch_endpoint_metadata_uses_non_nil_api_domain() {
let domain = NvLinkDomainId::from_str("9f4b45ec-705a-4af4-89f7-a112bc9c8f4e")
.expect("valid domain UUID");

check_values(
[
Check {
scenario: "domain is missing",
input: None,
expect: None,
},
Check {
scenario: "nil domain is absent",
input: Some(NvLinkDomainId::nil()),
expect: None,
},
Check {
scenario: "non-nil API switch field",
input: Some(domain),
expect: Some(domain),
},
],
|nvlink_domain_uuid| {
let metadata = switch_endpoint_metadata(
&rpc::forge::Switch {
config: Some(rpc::forge::SwitchConfig {
name: "switch-a".to_string(),
..Default::default()
}),
nvlink_domain_uuid,
..Default::default()
},
SwitchEndpointRole::Bmc,
false,
)
.expect("switch metadata");

let EndpointMetadata::Switch(switch) = metadata else {
panic!("expected switch metadata");
};

switch.nvlink_domain_uuid
},
);
}

#[tokio::test]
async fn cache_returns_existing_client_on_matching_kind() {
let mut cache: HashMap<MacAddress, CachedBmcClient> = HashMap::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ mod tests {
serial: "SN-SWITCH-001".to_string(),
slot_number: Some(7),
tray_index: Some(3),
nvlink_domain_uuid: None,
endpoint_role: SwitchEndpointRole::Host,
is_primary: false,
nmxc_enabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ mod tests {
serial: "SN-SWITCH-001".to_string(),
slot_number: Some(7),
tray_index: Some(3),
nvlink_domain_uuid: None,
endpoint_role: SwitchEndpointRole::Host,
is_primary: false,
nmxc_enabled: false,
Expand Down
6 changes: 6 additions & 0 deletions crates/health/src/collectors/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ impl Collector {
let _ = self.handle.await;
}

/// Returns a handle that can force the collector task to stop while its
/// normal shutdown future remains available to join the task.
pub(crate) fn abort_handle(&self) -> tokio::task::AbortHandle {
self.handle.abort_handle()
}

pub fn is_finished(&self) -> bool {
self.handle.is_finished()
}
Expand Down
13 changes: 12 additions & 1 deletion crates/health/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ pub struct StaticSwitchEndpoint {
pub slot_number: Option<i32>,
#[serde(alias = "compute_tray_index")]
pub tray_index: Option<i32>,

/// Optional non-nil NVLink domain UUID associated with this switch.
/// Invalid or nil values are omitted from telemetry.
pub nvlink_domain_uuid: Option<String>,

#[serde(default = "default_static_switch_endpoint_role")]
pub endpoint_role: StaticSwitchEndpointRole,
#[serde(default)]
Expand Down Expand Up @@ -1918,6 +1923,7 @@ mod tests {
serial: Some("switch-serial".to_string()),
slot_number: None,
tray_index: None,
nvlink_domain_uuid: None,
endpoint_role: StaticSwitchEndpointRole::Host,
is_primary: false,
nmxc_enabled: None,
Expand Down Expand Up @@ -3866,7 +3872,7 @@ ip = "10.0.1.2"
mac = "11:22:33:44:55:77"
username = "admin"
password = "pass"
switch = { id = "fsw100htjtiaehv1n5vh67tbmqq4eabcjdng40f7jupsadbedhruh6rag1l0", serial = "SN-SW-002", endpoint_role = "host", is_primary = false, nmxc_enabled = true, nmxt_enabled = true }
switch = { id = "fsw100htjtiaehv1n5vh67tbmqq4eabcjdng40f7jupsadbedhruh6rag1l0", serial = "SN-SW-002", endpoint_role = "host", is_primary = false, nmxc_enabled = true, nmxt_enabled = true, nvlink_domain_uuid = "9f4b45ec-705a-4af4-89f7-a112bc9c8f4e" }
"#;

let config: Config = Figment::new()
Expand All @@ -3884,6 +3890,11 @@ switch = { id = "fsw100htjtiaehv1n5vh67tbmqq4eabcjdng40f7jupsadbedhruh6rag1l0",
assert!(!switch.is_primary);
assert_eq!(switch.nmxc_enabled, Some(true));
assert_eq!(switch.nmxt_enabled, Some(true));

assert_eq!(
switch.nvlink_domain_uuid.as_deref(),
Some("9f4b45ec-705a-4af4-89f7-a112bc9c8f4e")
);
}

#[test]
Expand Down
Loading
Loading