mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
refactor(admin): use storage admin info (#3333)
This commit is contained in:
@@ -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-storage-admin-consumers`
|
- Branch: `overtrue/arch-admin-usecase-storage-info`
|
||||||
- Baseline: `origin/main` at `4b1714438e13afd2b44872bf45fbe084065c9d18`
|
- Baseline: `origin/main` at `8a90bda16ab233504ee2c4f9e15942c340d54631`
|
||||||
- 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 storage-class config consumer from the
|
- Rust code changes: migrate the admin use-case storage-info consumer from the
|
||||||
old `StorageAPI::set_drive_counts` import to the inventory-facing
|
old `StorageAPI::storage_info` trait import to the inventory-facing
|
||||||
`StorageAdminApi::set_drive_counts` contract.
|
`StorageAdminApi::storage_info` contract.
|
||||||
- CI/script changes: none
|
- CI/script changes: none
|
||||||
- Docs changes: record API-007 admin config consumer-migration context,
|
- Docs changes: record API-007 admin use-case consumer-migration context,
|
||||||
verification evidence, and expert review outcomes.
|
verification evidence, and expert review outcomes.
|
||||||
|
|
||||||
## Phase 0 Tasks
|
## Phase 0 Tasks
|
||||||
@@ -195,17 +195,20 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
|
|||||||
- [~] `API-007` Dual-route `get_disks` consumers.
|
- [~] `API-007` Dual-route `get_disks` consumers.
|
||||||
- Completed first slice: `rustfs/rustfs#3331` bound `ECStore` to
|
- Completed first slice: `rustfs/rustfs#3331` bound `ECStore` to
|
||||||
`StorageAdminApi` while keeping all consumers unchanged.
|
`StorageAdminApi` while keeping all consumers unchanged.
|
||||||
- Current branch slice: migrate the admin storage-class config consumer to
|
- Completed second slice: `rustfs/rustfs#3332` migrated the admin
|
||||||
|
storage-class config drive-count consumer to
|
||||||
`StorageAdminApi::set_drive_counts`.
|
`StorageAdminApi::set_drive_counts`.
|
||||||
- Acceptance: `rustfs/src/admin/service/config.rs` no longer imports old
|
- Current branch slice: migrate the admin use-case storage-info consumer to
|
||||||
`StorageAPI` only to read drive-count inventory, and `rustfs` owns an
|
`StorageAdminApi::storage_info`.
|
||||||
explicit dependency on the contract crate.
|
- Acceptance: `rustfs/src/app/admin_usecase.rs` no longer imports 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, storage-class parsing/default semantics, admin config validation,
|
behavior, admin storage-info response shape, data-usage capacity
|
||||||
readiness/capacity/heal/scanner consumers, and storage hot paths.
|
correction semantics, readiness/heal/scanner/RPC consumers, and storage hot
|
||||||
- Risk defense: keep this slice to the admin config drive-count consumer;
|
paths.
|
||||||
do not migrate `backend_info`, `local_storage_info`, readiness, heal,
|
- Risk defense: keep this slice to `DefaultAdminUsecase` storage-info reads;
|
||||||
scanner, or RPC consumers in the same PR.
|
do not migrate account-info `backend_info`, RPC `local_storage_info`,
|
||||||
|
readiness, heal, scanner, or storage hot-path consumers in the same PR.
|
||||||
|
|
||||||
## Phase 8 Background Controller Tasks
|
## Phase 8 Background Controller Tasks
|
||||||
|
|
||||||
@@ -249,19 +252,17 @@ Status values: `[ ]` not started, `[~]` in progress, `[x]` complete, `[!]` block
|
|||||||
|
|
||||||
| Expert | Status | Notes |
|
| Expert | Status | Notes |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| Quality/architecture | pass | Confirmed this remains a narrow admin config consumer-migration slice, with an explicit `rustfs` dependency on the contract crate and no ECStore or storage-api boundary reshaping. |
|
| 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. |
|
||||||
| Migration preservation | pass | Confirmed storage-class parsing/default behavior, old `StorageAPI`, `StorageAPI::get_disks`, ECStore handlers, and storage hot paths remain unchanged. |
|
| 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. |
|
||||||
| Testing/verification | pass | Confirmed focused admin config tests, dependency guards, migration guards, formatting, diff hygiene, and full pre-commit evidence passed before push. |
|
| Testing/verification | pass | Confirmed focused admin use-case tests, migration guards, formatting, diff hygiene, and full pre-commit evidence passed before push. |
|
||||||
|
|
||||||
## Verification Notes
|
## Verification Notes
|
||||||
|
|
||||||
Passed:
|
Passed:
|
||||||
- `cargo check -p rustfs --lib`
|
|
||||||
- `cargo check -p rustfs-storage-api -p rustfs-ecstore -p rustfs --lib`
|
|
||||||
- `cargo test -p rustfs admin::service::config --lib`
|
|
||||||
- `cargo tree -p rustfs --edges normal`
|
|
||||||
- `cargo fmt --all`
|
|
||||||
- `cargo fmt --all --check`
|
- `cargo fmt --all --check`
|
||||||
|
- `cargo check -p rustfs --lib`
|
||||||
|
- `cargo test -p rustfs app::admin_usecase --lib`
|
||||||
|
- `cargo check -p rustfs-storage-api -p rustfs-ecstore -p rustfs --lib`
|
||||||
- `./scripts/check_architecture_migration_rules.sh`
|
- `./scripts/check_architecture_migration_rules.sh`
|
||||||
- `./scripts/check_layer_dependencies.sh`
|
- `./scripts/check_layer_dependencies.sh`
|
||||||
- `./scripts/check_metrics_migration_refs.sh`
|
- `./scripts/check_metrics_migration_refs.sh`
|
||||||
@@ -270,14 +271,11 @@ Passed:
|
|||||||
- `make NUM_CORES=1 pre-commit`
|
- `make NUM_CORES=1 pre-commit`
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
- This branch adds a direct `rustfs` dependency on `rustfs-storage-api` so the
|
- This branch relies on the existing direct `rustfs` dependency on
|
||||||
admin config consumer can call the contract crate instead of importing the
|
`rustfs-storage-api` from the previous API-007 slice.
|
||||||
old ECStore `StorageAPI` trait.
|
- Only `DefaultAdminUsecase` storage-info read calls changed.
|
||||||
- `./scripts/check_layer_dependencies.sh` passes with the new dependency.
|
- No existing ECStore handler, admin route, readiness path, heal/scanner
|
||||||
- Only the admin storage-class config drive-count consumer changed.
|
consumer, RPC consumer, or storage hot path is changed.
|
||||||
- No existing ECStore handler, admin route, readiness path, capacity
|
|
||||||
calculation, heal/scanner 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.
|
||||||
@@ -286,7 +284,7 @@ Notes:
|
|||||||
|
|
||||||
- Keep this API-007 slice as a focused `consumer-migration` PR.
|
- Keep this API-007 slice as a focused `consumer-migration` PR.
|
||||||
- Do not migrate account-info `backend_info`, RPC `local_storage_info`,
|
- Do not migrate account-info `backend_info`, RPC `local_storage_info`,
|
||||||
readiness, capacity, heal, or scanner consumers in this PR.
|
readiness, heal, scanner, or 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
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ use rustfs_ecstore::data_usage::{apply_bucket_usage_memory_overlay, load_data_us
|
|||||||
use rustfs_ecstore::endpoints::EndpointServerPools;
|
use rustfs_ecstore::endpoints::EndpointServerPools;
|
||||||
use rustfs_ecstore::new_object_layer_fn;
|
use rustfs_ecstore::new_object_layer_fn;
|
||||||
use rustfs_ecstore::pools::{PoolDecommissionInfo, PoolStatus, get_total_usable_capacity, get_total_usable_capacity_free};
|
use rustfs_ecstore::pools::{PoolDecommissionInfo, PoolStatus, get_total_usable_capacity, get_total_usable_capacity_free};
|
||||||
use rustfs_ecstore::store_api::StorageAPI;
|
|
||||||
use rustfs_madmin::{InfoMessage, StorageInfo};
|
use rustfs_madmin::{InfoMessage, StorageInfo};
|
||||||
|
use rustfs_storage_api::StorageAdminApi;
|
||||||
use s3s::S3ErrorCode;
|
use s3s::S3ErrorCode;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info, warn};
|
||||||
@@ -125,7 +125,7 @@ impl DefaultAdminUsecase {
|
|||||||
return Err(Self::app_error(S3ErrorCode::InternalError, "Not init"));
|
return Err(Self::app_error(S3ErrorCode::InternalError, "Not init"));
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(store.storage_info().await)
|
Ok(StorageAdminApi::storage_info(store.as_ref()).await)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute_query_data_usage_info(&self) -> AdminUsecaseResult<DataUsageInfo> {
|
pub async fn execute_query_data_usage_info(&self) -> AdminUsecaseResult<DataUsageInfo> {
|
||||||
@@ -139,7 +139,7 @@ impl DefaultAdminUsecase {
|
|||||||
})?;
|
})?;
|
||||||
apply_bucket_usage_memory_overlay(&mut info).await;
|
apply_bucket_usage_memory_overlay(&mut info).await;
|
||||||
|
|
||||||
let storage_info = store.storage_info().await;
|
let storage_info = StorageAdminApi::storage_info(store.as_ref()).await;
|
||||||
|
|
||||||
// Keep the same capacity correction behavior as the previous admin handler implementation.
|
// Keep the same capacity correction behavior as the previous admin handler implementation.
|
||||||
const MAX_REASONABLE_CAPACITY: u64 = 100_000 * 1024 * 1024 * 1024 * 1024; // 100 PiB
|
const MAX_REASONABLE_CAPACITY: u64 = 100_000 * 1024 * 1024 * 1024 * 1024; // 100 PiB
|
||||||
|
|||||||
Reference in New Issue
Block a user