From 2c9751c399c74b413e318c682619051a57ef72b7 Mon Sep 17 00:00:00 2001 From: Thomas McRoberts Date: Wed, 20 May 2026 17:56:19 +0000 Subject: [PATCH 1/2] fix: fields in nvlink-info command Use the correct fields when parsing the NMX-C response in the nvlink-info admin-cli command. Also, return an error if any of the fields aren't parsed correctly instead of pushing a default value. Signed-off-by: Thomas McRoberts --- .../admin-cli/src/machine/nvlink_info/cmd.rs | 62 +++++++++++-------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/crates/admin-cli/src/machine/nvlink_info/cmd.rs b/crates/admin-cli/src/machine/nvlink_info/cmd.rs index bb647d0dba..34a70d1352 100644 --- a/crates/admin-cli/src/machine/nvlink_info/cmd.rs +++ b/crates/admin-cli/src/machine/nvlink_info/cmd.rs @@ -146,17 +146,20 @@ pub async fn handle_nvlink_info_populate( })?; let domain_uuid = list_json - .get("DomainUUID") + .get("server_header") + .and_then(|h| h.get("domain_uuid")) .and_then(|v| v.as_str()) .filter(|s| !s.is_empty()) .ok_or_else(|| { - CarbideCliError::GenericError( - "No non-empty DomainUUID in NMX-C GPU list response".to_string(), - ) + CarbideCliError::GenericError("No domain_uuid in NMX-C server_header".to_string()) + })? + .parse::() + .map_err(|e| { + CarbideCliError::GenericError(format!("Failed to parse domain_uuid: {}", e)) })?; let gpus_json = list_json - .get("Gpus") + .get("gpu_info_list") .and_then(|v| v.as_array()) .ok_or_else(|| { CarbideCliError::GenericError("No Gpus array in NMX-C GPU list response".to_string()) @@ -165,27 +168,43 @@ pub async fn handle_nvlink_info_populate( let mut gpus: Vec = Vec::new(); for gpu_json in gpus_json { let gpu_tray_index = gpu_json - .get("LocationInfo") - .and_then(|loc| loc.get("TrayIndex")) + .get("loc") + .and_then(|loc| loc.get("tray_index")) .and_then(|v| v.as_i64()) - .unwrap_or(0) as i32; + .map(|v| v as i32) + .ok_or_else(|| { + CarbideCliError::GenericError( + "GPU entry missing loc.tray_index in NMX-C GPU list response".to_string(), + ) + })?; if gpu_tray_index != tray_index { continue; } let gpu_device_id = gpu_json - .get("DeviceID") + .get("gpu_id") .and_then(|v| v.as_i64()) - .unwrap_or(0) as i32; - let gpu_device_uid = gpu_json - .get("DeviceUID") - .and_then(|v| v.as_u64()) - .unwrap_or(0); + .map(|v| v as i32) + .ok_or_else(|| { + CarbideCliError::GenericError( + "GPU entry missing gpu_id in NMX-C GPU list response".to_string(), + ) + })?; + let gpu_device_uid = gpu_json.get("gpu_uid").and_then(|v| v.as_u64()).ok_or_else(|| { + CarbideCliError::GenericError( + "GPU entry missing gpu_uid in NMX-C GPU list response".to_string(), + ) + })?; let gpu_slot_id = gpu_json - .get("LocationInfo") - .and_then(|loc| loc.get("SlotID")) + .get("loc") + .and_then(|loc| loc.get("slot_id")) .and_then(|v| v.as_i64()) - .unwrap_or(0) as i32; + .map(|v| v as i32) + .ok_or_else(|| { + CarbideCliError::GenericError( + "GPU entry missing loc.slot_id in NMX-C GPU list response".to_string(), + ) + })?; gpus.push(forgerpc::NvLinkGpu { device_id: gpu_device_id, @@ -202,16 +221,9 @@ pub async fn handle_nvlink_info_populate( ))); } - // Parse domain_uuid as UUID - let domain_uuid_parsed = uuid::Uuid::parse_str(domain_uuid).map_err(|e| { - CarbideCliError::GenericError(format!("Failed to parse domain_uuid: {}", e)) - })?; - // Build the nvlink_info structure for RPC let nvlink_info_rpc = forgerpc::MachineNvLinkInfo { - domain_uuid: Some(carbide_uuid::nvlink::NvLinkDomainId::from( - domain_uuid_parsed, - )), + domain_uuid: Some(carbide_uuid::nvlink::NvLinkDomainId::from(domain_uuid)), gpus: gpus.clone(), chassis_serial: serial_number.clone(), }; From 2ba872513d65daef00202ec49969c54f6877e66c Mon Sep 17 00:00:00 2001 From: Thomas McRoberts Date: Thu, 21 May 2026 08:53:10 +0000 Subject: [PATCH 2/2] fix: formatting Signed-off-by: Thomas McRoberts --- crates/admin-cli/src/machine/nvlink_info/cmd.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/admin-cli/src/machine/nvlink_info/cmd.rs b/crates/admin-cli/src/machine/nvlink_info/cmd.rs index 34a70d1352..3aefe4139d 100644 --- a/crates/admin-cli/src/machine/nvlink_info/cmd.rs +++ b/crates/admin-cli/src/machine/nvlink_info/cmd.rs @@ -190,11 +190,14 @@ pub async fn handle_nvlink_info_populate( "GPU entry missing gpu_id in NMX-C GPU list response".to_string(), ) })?; - let gpu_device_uid = gpu_json.get("gpu_uid").and_then(|v| v.as_u64()).ok_or_else(|| { - CarbideCliError::GenericError( - "GPU entry missing gpu_uid in NMX-C GPU list response".to_string(), - ) - })?; + let gpu_device_uid = gpu_json + .get("gpu_uid") + .and_then(|v| v.as_u64()) + .ok_or_else(|| { + CarbideCliError::GenericError( + "GPU entry missing gpu_uid in NMX-C GPU list response".to_string(), + ) + })?; let gpu_slot_id = gpu_json .get("loc") .and_then(|loc| loc.get("slot_id"))