refactor(admin): use storage admin reads (#3334)

This commit is contained in:
安正超
2026-06-11 07:48:38 +08:00
committed by GitHub
parent b48d7b1fa5
commit 8ae0cad667
4 changed files with 48 additions and 42 deletions
+41 -36
View File
@@ -5,15 +5,15 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
## Current Context ## Current Context
- Issue: [`rustfs/backlog#660`](https://github.com/rustfs/backlog/issues/660) - Issue: [`rustfs/backlog#660`](https://github.com/rustfs/backlog/issues/660)
- Branch: `overtrue/arch-admin-usecase-storage-info` - Branch: `overtrue/arch-admin-readiness-storage-admin`
- Baseline: `origin/main` at `8a90bda16ab233504ee2c4f9e15942c340d54631` - Baseline: `origin/main` at `b48d7b1fa514e5da274d652a0cb7f282521f46c0`
- PR type for this branch: `consumer-migration` - PR type for this branch: `consumer-migration`
- Runtime behavior changes: none. - Runtime behavior changes: none.
- Rust code changes: migrate the admin use-case storage-info consumer from the - Rust code changes: migrate grouped admin/readiness read-side consumers from
old `StorageAPI::storage_info` trait import to the inventory-facing old `StorageAPI::{backend_info, storage_info}` trait imports to the
`StorageAdminApi::storage_info` contract. inventory-facing `StorageAdminApi` contract.
- CI/script changes: none - CI/script changes: none.
- Docs changes: record API-007 admin use-case consumer-migration context, - Docs changes: record API-007 grouped consumer-migration context,
verification evidence, and expert review outcomes. verification evidence, and expert review outcomes.
## Phase 0 Tasks ## Phase 0 Tasks
@@ -198,17 +198,21 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
- Completed second slice: `rustfs/rustfs#3332` migrated the admin - Completed second slice: `rustfs/rustfs#3332` migrated the admin
storage-class config drive-count consumer to storage-class config drive-count consumer to
`StorageAdminApi::set_drive_counts`. `StorageAdminApi::set_drive_counts`.
- Current branch slice: migrate the admin use-case storage-info consumer to - Completed third slice: `rustfs/rustfs#3333` migrated
`DefaultAdminUsecase` storage-info reads to
`StorageAdminApi::storage_info`. `StorageAdminApi::storage_info`.
- Acceptance: `rustfs/src/app/admin_usecase.rs` no longer imports old - Current branch slice: migrate grouped read-side admin/readiness consumers:
`StorageAPI` only to read admin storage information. account-info `backend_info`, rebalance status `storage_info`, and runtime
readiness `storage_info`.
- Acceptance: account-info, rebalance status, and readiness no longer import
old `StorageAPI` only to read admin storage information.
- Must preserve: old `StorageAPI` trait shape, `StorageAPI::get_disks` - Must preserve: old `StorageAPI` trait shape, `StorageAPI::get_disks`
behavior, admin storage-info response shape, data-usage capacity behavior, account-info response shape, rebalance used-space aggregation,
correction semantics, readiness/heal/scanner/RPC consumers, and storage hot readiness degraded-state semantics, RPC `local_storage_info`, heal/scanner
paths. consumers, and storage hot paths.
- Risk defense: keep this slice to `DefaultAdminUsecase` storage-info reads; - Risk defense: group only read-side callers that delegate to the existing
do not migrate account-info `backend_info`, RPC `local_storage_info`, ECStore admin info implementation; do not migrate RPC `local_storage_info`,
readiness, heal, scanner, or storage hot-path consumers in the same PR. heal, scanner, observability, or storage hot-path consumers in this PR.
## Phase 8 Background Controller Tasks ## Phase 8 Background Controller Tasks
@@ -252,39 +256,40 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
| Expert | Status | Notes | | Expert | Status | Notes |
|---|---|---| |---|---|---|
| Quality/architecture | pass | Confirmed this remains a narrow admin use-case storage-info consumer-migration slice, with no ECStore, `StorageAPI`, storage-api, manifest, or lockfile boundary reshaping. | | Quality/architecture | pass | Confirmed the diff stays limited to three read-side consumers and migration notes, with no manifest, ECStore, storage-api, RPC, heal, scanner, observability, or hot-path scope creep. |
| Migration preservation | pass | Confirmed admin storage-info response shape, capacity correction semantics, old `StorageAPI`, `StorageAPI::get_disks`, ECStore handlers, and storage hot paths remain unchanged. | | Migration preservation | pass | Confirmed the new and old ECStore trait paths still delegate to the same backend/storage-info handlers, while account-info response construction, rebalance aggregation, and readiness cache/degraded-state logic remain unchanged. |
| Testing/verification | pass | Confirmed focused admin use-case tests, migration guards, formatting, diff hygiene, and full pre-commit evidence passed before push. | | Testing/verification | pass | Confirmed touched-consumer focused tests, compile checks, migration guards, diff hygiene, and full pre-commit evidence are sufficient; no missing success-path integration test is a blocker for this call-path migration. |
## Verification Notes ## Verification Notes
Passed: Passed:
- `cargo fmt --all --check` - `cargo fmt --all --check`.
- `cargo check -p rustfs --lib` - `cargo check -p rustfs --lib`.
- `cargo test -p rustfs app::admin_usecase --lib` - `cargo test -p rustfs admin::handlers::account_info --lib`; 3 passed.
- `cargo check -p rustfs-storage-api -p rustfs-ecstore -p rustfs --lib` - `cargo test -p rustfs admin::handlers::rebalance --lib`; 19 passed.
- `./scripts/check_architecture_migration_rules.sh` - `cargo test -p rustfs server::readiness --lib`; 13 passed.
- `./scripts/check_layer_dependencies.sh` - `cargo check -p rustfs-storage-api -p rustfs-ecstore -p rustfs --lib`.
- `./scripts/check_metrics_migration_refs.sh` - `./scripts/check_architecture_migration_rules.sh`.
- `./scripts/check_unsafe_code_allowances.sh` - `./scripts/check_layer_dependencies.sh`.
- `git diff --check` - `./scripts/check_metrics_migration_refs.sh`.
- `make NUM_CORES=1 pre-commit` - `./scripts/check_unsafe_code_allowances.sh`.
- `git diff --check`.
- `make NUM_CORES=1 pre-commit`.
Notes: Notes:
- This branch relies on the existing direct `rustfs` dependency on - This branch relies on the existing direct `rustfs` dependency on
`rustfs-storage-api` from the previous API-007 slice. `rustfs-storage-api` from earlier API-007 slices.
- Only `DefaultAdminUsecase` storage-info read calls changed. - No ECStore handler, old `StorageAPI` trait, RPC consumer, heal/scanner
- No existing ECStore handler, admin route, readiness path, heal/scanner consumer, observability consumer, or storage hot path is changed.
consumer, RPC consumer, or storage hot path is changed.
- Full pre-commit passed with nextest `5757 passed, 111 skipped`; workspace - Full pre-commit passed with nextest `5757 passed, 111 skipped`; workspace
doctests passed. doctests passed.
- No temporary compatibility shim was added. - No temporary compatibility shim was added.
## Handoff Notes ## Handoff Notes
- Keep this API-007 slice as a focused `consumer-migration` PR. - Keep this API-007 slice as a grouped read-side `consumer-migration` PR.
- Do not migrate account-info `backend_info`, RPC `local_storage_info`, - Do not migrate RPC `local_storage_info`, heal, scanner, observability, or
readiness, heal, scanner, or storage hot-path consumers in this PR. storage hot-path consumers in this PR.
- Do not remove or route around `StorageAPI::get_disks` in this PR. - Do not remove or route around `StorageAPI::get_disks` in this PR.
- Do not make the old `StorageAPI` trait inherit `StorageAdminApi` in this PR. - Do not make the old `StorageAPI` trait inherit `StorageAdminApi` in this PR.
- Do not add temporary compatibility code unless a matching - Do not add temporary compatibility code unless a matching
+3 -2
View File
@@ -22,10 +22,11 @@ use matchit::Params;
use rustfs_credentials::get_global_action_cred; use rustfs_credentials::get_global_action_cred;
use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys; use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys;
use rustfs_ecstore::new_object_layer_fn; use rustfs_ecstore::new_object_layer_fn;
use rustfs_ecstore::store_api::{BucketOperations, BucketOptions, StorageAPI}; use rustfs_ecstore::store_api::{BucketOperations, BucketOptions};
use rustfs_policy::policy::BucketPolicy; use rustfs_policy::policy::BucketPolicy;
use rustfs_policy::policy::default::DEFAULT_POLICIES; use rustfs_policy::policy::default::DEFAULT_POLICIES;
use rustfs_policy::policy::{Args, action::Action, action::S3Action}; use rustfs_policy::policy::{Args, action::Action, action::S3Action};
use rustfs_storage_api::StorageAdminApi;
use s3s::header::CONTENT_TYPE; use s3s::header::CONTENT_TYPE;
use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, s3_error}; use s3s::{Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, s3_error};
use serde::Serialize; use serde::Serialize;
@@ -187,7 +188,7 @@ impl Operation for AccountInfoHandler {
let mut account_info = rustfs_madmin::AccountInfo { let mut account_info = rustfs_madmin::AccountInfo {
account_name, account_name,
server: store.backend_info().await, server: StorageAdminApi::backend_info(store.as_ref()).await,
policy: serde_json::Value::String(policy_str), policy: serde_json::Value::String(policy_str),
..Default::default() ..Default::default()
}; };
+2 -2
View File
@@ -25,7 +25,6 @@ use hyper::Method;
use matchit::Params; use matchit::Params;
use rustfs_ecstore::rebalance::RebalanceMeta; use rustfs_ecstore::rebalance::RebalanceMeta;
use rustfs_ecstore::{ use rustfs_ecstore::{
StorageAPI,
error::StorageError, error::StorageError,
new_object_layer_fn, new_object_layer_fn,
notification_sys::get_global_notification_sys, notification_sys::get_global_notification_sys,
@@ -34,6 +33,7 @@ use rustfs_ecstore::{
store_api::BucketOptions, store_api::BucketOptions,
}; };
use rustfs_policy::policy::action::{Action, AdminAction}; use rustfs_policy::policy::action::{Action, AdminAction};
use rustfs_storage_api::StorageAdminApi;
use s3s::{ use s3s::{
Body, S3Request, S3Response, S3Result, Body, S3Request, S3Response, S3Result,
header::{CONTENT_LENGTH, CONTENT_TYPE}, header::{CONTENT_LENGTH, CONTENT_TYPE},
@@ -347,7 +347,7 @@ impl Operation for RebalanceStatus {
} }
// Compute disk usage percentage // Compute disk usage percentage
let si = store.storage_info().await; let si = StorageAdminApi::storage_info(store.as_ref()).await;
let mut disk_stats = vec![DiskStat::default(); store.pools.len()]; let mut disk_stats = vec![DiskStat::default(); store.pools.len()];
for disk in si.disks.iter() { for disk in si.disks.iter() {
+2 -2
View File
@@ -24,9 +24,9 @@ use rustfs_common::GlobalReadiness;
use rustfs_ecstore::global::is_dist_erasure; use rustfs_ecstore::global::is_dist_erasure;
use rustfs_ecstore::global::{get_global_endpoints_opt, get_global_lock_clients}; use rustfs_ecstore::global::{get_global_endpoints_opt, get_global_lock_clients};
use rustfs_ecstore::new_object_layer_fn; use rustfs_ecstore::new_object_layer_fn;
use rustfs_ecstore::store_api::StorageAPI;
use rustfs_iam::get_global_iam_sys; use rustfs_iam::get_global_iam_sys;
use rustfs_madmin::{Disk, StorageInfo}; use rustfs_madmin::{Disk, StorageInfo};
use rustfs_storage_api::StorageAdminApi;
use std::future::Future; use std::future::Future;
use std::pin::Pin; use std::pin::Pin;
use std::sync::Arc; use std::sync::Arc;
@@ -489,7 +489,7 @@ async fn collect_dependency_readiness_uncached() -> DependencyReadiness {
async fn collect_storage_readiness_uncached() -> bool { async fn collect_storage_readiness_uncached() -> bool {
if let Some(store) = new_object_layer_fn() { if let Some(store) = new_object_layer_fn() {
let storage_info = store.storage_info().await; let storage_info = StorageAdminApi::storage_info(store.as_ref()).await;
storage_ready_from_runtime_state(&storage_info) storage_ready_from_runtime_state(&storage_info)
} else { } else {
false false