From e06caad94a2439cde70096e0501df9453d04220b Mon Sep 17 00:00:00 2001 From: GatewayJ <18332154+GatewayJ@users.noreply.github.com> Date: Wed, 29 Jul 2026 22:22:59 +0800 Subject: [PATCH] fix(monitoring): parse wrapped tenant server info --- src/sts/admin_ops.rs | 5 +++-- src/sts/rustfs_client.rs | 5 +++++ src/sts/tests.rs | 41 +++++++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/sts/admin_ops.rs b/src/sts/admin_ops.rs index 707f2bd..395e148 100644 --- a/src/sts/admin_ops.rs +++ b/src/sts/admin_ops.rs @@ -22,7 +22,7 @@ use super::helpers::{body_mentions_not_found, build_query_pairs, extract_canned_ use super::{ ADD_CANNED_POLICY_PATH, ADD_USER_PATH, ADMIN_SIGNING_SERVICE, INFO_CANNED_POLICY_PATH, JSON_CONTENT_TYPE, LIST_CANNED_POLICIES_PATH, RustfsAdminClient, RustfsClientError, - RustfsServerInfo, SERVER_INFO_PATH, SET_POLICY_PATH, USER_INFO_PATH, + RustfsServerInfo, RustfsServerInfoResponse, SERVER_INFO_PATH, SET_POLICY_PATH, USER_INFO_PATH, }; use reqwest::StatusCode; use serde_json::Value; @@ -148,7 +148,8 @@ impl RustfsAdminClient { let body = self .send_admin_request("GET", SERVER_INFO_PATH, "", "", None) .await?; - serde_json::from_str::(&body) + serde_json::from_str::(&body) + .map(|response| response.info) .map_err(|_| RustfsClientError::ParseResponseFailed) } diff --git a/src/sts/rustfs_client.rs b/src/sts/rustfs_client.rs index c5d38b4..865c27f 100644 --- a/src/sts/rustfs_client.rs +++ b/src/sts/rustfs_client.rs @@ -138,6 +138,11 @@ pub struct RustfsServerInfo { pub pools: Option>>, } +#[derive(Debug, Clone, serde::Deserialize, PartialEq)] +pub(super) struct RustfsServerInfoResponse { + pub info: RustfsServerInfo, +} + #[derive(Debug, Clone, Default, serde::Deserialize, PartialEq)] pub struct RustfsServerUsage { #[serde(default)] diff --git a/src/sts/tests.rs b/src/sts/tests.rs index 72f0482..4934040 100644 --- a/src/sts/tests.rs +++ b/src/sts/tests.rs @@ -563,7 +563,7 @@ async fn add_canned_policy_reports_upstream_policy_parse_error() { } #[tokio::test] -async fn server_info_uses_expected_path_and_parses_health_fields() { +async fn server_info_uses_expected_path_and_parses_wrapped_health_fields() { let capture = Capture::default(); let route_capture = capture.clone(); @@ -586,25 +586,32 @@ async fn server_info_uses_expected_path_and_parses_health_fields() { ( StatusCode::OK, serde_json::json!({ - "usage": {"size": 42}, - "backend": { - "onlineDisks": 3, - "offlineDisks": 1, - "standardSCParity": 2, - "totalSets": [1], - "totalDrivesPerSet": [4] - }, - "pools": { - "0": { + "info": { + "usage": {"size": 42}, + "backend": { + "onlineDisks": 3, + "offlineDisks": 1, + "standardSCParity": 2, + "totalSets": [1], + "totalDrivesPerSet": [4] + }, + "pools": { "0": { - "rawUsage": 100, - "rawCapacity": 400, - "usage": 50, - "objectsCount": 2, - "healDisks": 1 + "0": { + "rawUsage": 100, + "rawCapacity": 400, + "usage": 50, + "objectsCount": 2, + "healDisks": 1 + } } } - } + }, + "admin_discovery": { + "runtimeCapabilities": "/rustfs/admin/v4/runtime/capabilities", + "clusterSnapshot": "/rustfs/admin/v4/cluster/snapshot", + "extensionsCatalog": "/rustfs/admin/v4/extensions/catalog" + }, }) .to_string(), )