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
5 changes: 3 additions & 2 deletions src/sts/admin_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -148,7 +148,8 @@ impl RustfsAdminClient {
let body = self
.send_admin_request("GET", SERVER_INFO_PATH, "", "", None)
.await?;
serde_json::from_str::<RustfsServerInfo>(&body)
serde_json::from_str::<RustfsServerInfoResponse>(&body)
.map(|response| response.info)
.map_err(|_| RustfsClientError::ParseResponseFailed)
}

Expand Down
5 changes: 5 additions & 0 deletions src/sts/rustfs_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ pub struct RustfsServerInfo {
pub pools: Option<BTreeMap<String, BTreeMap<String, RustfsErasureSetInfo>>>,
}

#[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)]
Expand Down
41 changes: 24 additions & 17 deletions src/sts/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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(),
)
Expand Down
Loading