mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-21 03:46:37 +00:00
refactor: flatten test harness storage compat aliases (#3596)
* refactor: flatten test harness storage compat aliases * refactor: flatten rustfs storage compat aliases (#3597) * refactor: prune runtime storage compat surface (#3598) * refactor: flatten runtime secondary storage compat (#3599) * docs: add scheduler placement profiling baselines (#3600) * feat: add observability topology capability contracts (#3601)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
// Used by test_distributed_lock_4_nodes_grpc in lock.rs
|
||||
#![allow(dead_code)]
|
||||
|
||||
use crate::storage_compat::ecstore::rpc::node_service_time_out_client_no_auth;
|
||||
use crate::storage_compat::node_service_time_out_client_no_auth;
|
||||
use async_trait::async_trait;
|
||||
use rustfs_lock::{
|
||||
LockClient, LockError, LockId, LockInfo, LockRequest, LockResponse, LockStats, LockStatus, LockType, Result,
|
||||
@@ -41,10 +41,7 @@ impl GrpcLockClient {
|
||||
&self,
|
||||
) -> Result<
|
||||
rustfs_protos::proto_gen::node_service::node_service_client::NodeServiceClient<
|
||||
tonic::service::interceptor::InterceptedService<
|
||||
tonic::transport::Channel,
|
||||
crate::storage_compat::ecstore::rpc::TonicInterceptor,
|
||||
>,
|
||||
tonic::service::interceptor::InterceptedService<tonic::transport::Channel, crate::storage_compat::TonicInterceptor>,
|
||||
>,
|
||||
> {
|
||||
node_service_time_out_client_no_auth(&self.addr)
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
use crate::common::workspace_root;
|
||||
use crate::storage_compat::ecstore::disk::{VolumeInfo, WalkDirOptions};
|
||||
use crate::storage_compat::ecstore::rpc::{TonicInterceptor, gen_tonic_signature_interceptor, node_service_time_out_client};
|
||||
use crate::storage_compat::{TonicInterceptor, gen_tonic_signature_interceptor, node_service_time_out_client};
|
||||
use crate::storage_compat::{VolumeInfo, WalkDirOptions};
|
||||
use futures::future::join_all;
|
||||
use rmp_serde::{Deserializer, Serializer};
|
||||
use rustfs_filemeta::{MetaCacheEntry, MetacacheReader, MetacacheWriter};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
use crate::common::{
|
||||
RustFSTestEnvironment, awscurl_available, awscurl_post_sts_form_urlencoded, init_logging, local_http_client,
|
||||
};
|
||||
use crate::storage_compat::ecstore::bucket::bucket_target_sys::BucketTargetSys;
|
||||
use crate::storage_compat::BucketTargetSys;
|
||||
use aws_sdk_s3::config::{Credentials, Region};
|
||||
use aws_sdk_s3::primitives::ByteStream;
|
||||
use aws_sdk_s3::types::{BucketVersioningStatus, VersioningConfiguration};
|
||||
|
||||
@@ -12,22 +12,13 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub(crate) mod ecstore {
|
||||
#![allow(unused_imports)]
|
||||
#![allow(dead_code, unused_imports)]
|
||||
|
||||
pub(crate) mod bucket {
|
||||
pub(crate) mod bucket_target_sys {
|
||||
pub(crate) use rustfs_ecstore::bucket::bucket_target_sys::BucketTargetSys;
|
||||
}
|
||||
}
|
||||
pub(crate) type BucketTargetSys = rustfs_ecstore::bucket::bucket_target_sys::BucketTargetSys;
|
||||
pub(crate) type TonicInterceptor = rustfs_ecstore::rpc::TonicInterceptor;
|
||||
pub(crate) type VolumeInfo = rustfs_ecstore::disk::VolumeInfo;
|
||||
pub(crate) type WalkDirOptions = rustfs_ecstore::disk::WalkDirOptions;
|
||||
|
||||
pub(crate) mod disk {
|
||||
pub(crate) use rustfs_ecstore::disk::{VolumeInfo, WalkDirOptions};
|
||||
}
|
||||
|
||||
pub(crate) mod rpc {
|
||||
pub(crate) use rustfs_ecstore::rpc::{
|
||||
TonicInterceptor, gen_tonic_signature_interceptor, node_service_time_out_client, node_service_time_out_client_no_auth,
|
||||
};
|
||||
}
|
||||
}
|
||||
pub(crate) use rustfs_ecstore::rpc::{
|
||||
gen_tonic_signature_interceptor, node_service_time_out_client, node_service_time_out_client_no_auth,
|
||||
};
|
||||
|
||||
@@ -12,28 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub(crate) mod ecstore {
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
pub(crate) mod bucket {
|
||||
pub(crate) mod metadata_sys {
|
||||
pub(crate) use rustfs_ecstore::bucket::metadata_sys::init_bucket_metadata_sys;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod disk {
|
||||
pub(crate) use rustfs_ecstore::disk::DiskStore;
|
||||
|
||||
pub(crate) mod endpoint {
|
||||
pub(crate) use rustfs_ecstore::disk::endpoint::Endpoint;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod endpoints {
|
||||
pub(crate) use rustfs_ecstore::endpoints::{EndpointServerPools, Endpoints, PoolEndpoints};
|
||||
}
|
||||
|
||||
pub(crate) mod store {
|
||||
pub(crate) use rustfs_ecstore::store::{ECStore, init_local_disks};
|
||||
}
|
||||
}
|
||||
pub(crate) use rustfs_ecstore::bucket::metadata_sys::init_bucket_metadata_sys;
|
||||
pub(crate) use rustfs_ecstore::disk::{DiskStore, endpoint::Endpoint};
|
||||
pub(crate) use rustfs_ecstore::endpoints::{EndpointServerPools, Endpoints, PoolEndpoints};
|
||||
pub(crate) use rustfs_ecstore::store::ECStore;
|
||||
pub(crate) use rustfs_ecstore::store::init_local_disks;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
mod common;
|
||||
|
||||
use crate::common::storage_compat::ecstore::disk::endpoint::Endpoint;
|
||||
use crate::common::storage_compat::ecstore::endpoints::{EndpointServerPools, Endpoints, PoolEndpoints};
|
||||
use crate::common::storage_compat::{ECStore, Endpoint, EndpointServerPools, Endpoints, PoolEndpoints, init_local_disks};
|
||||
use std::net::SocketAddr;
|
||||
use tempfile::TempDir;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
@@ -73,12 +72,10 @@ async fn test_endpoint_index_settings() -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
// test ECStore initialization
|
||||
crate::common::storage_compat::ecstore::store::init_local_disks(endpoint_pools.clone()).await?;
|
||||
init_local_disks(endpoint_pools.clone()).await?;
|
||||
|
||||
let server_addr: SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||
let ecstore =
|
||||
crate::common::storage_compat::ecstore::store::ECStore::new(server_addr, endpoint_pools, CancellationToken::new())
|
||||
.await?;
|
||||
let ecstore = ECStore::new(server_addr, endpoint_pools, CancellationToken::new()).await?;
|
||||
|
||||
println!("ECStore initialized successfully with {} pools", ecstore.pools.len());
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use rustfs_heal::heal::{
|
||||
|
||||
#[test]
|
||||
fn test_heal_event_to_heal_request_no_panic() {
|
||||
use crate::common::storage_compat::ecstore::disk::endpoint::Endpoint;
|
||||
use crate::common::storage_compat::Endpoint;
|
||||
|
||||
// Test that invalid pool/set indices don't cause panic
|
||||
// Create endpoint using try_from or similar method
|
||||
@@ -47,7 +47,7 @@ fn test_heal_event_to_heal_request_no_panic() {
|
||||
|
||||
#[test]
|
||||
fn test_heal_event_to_heal_request_valid_indices() {
|
||||
use crate::common::storage_compat::ecstore::disk::endpoint::Endpoint;
|
||||
use crate::common::storage_compat::Endpoint;
|
||||
|
||||
// Test that valid indices work correctly
|
||||
let endpoint_result = Endpoint::try_from("http://localhost:9000");
|
||||
@@ -192,14 +192,11 @@ fn test_heal_task_status_atomic_update() {
|
||||
}
|
||||
async fn get_disk_status(
|
||||
&self,
|
||||
_endpoint: &crate::common::storage_compat::ecstore::disk::endpoint::Endpoint,
|
||||
_endpoint: &crate::common::storage_compat::Endpoint,
|
||||
) -> rustfs_heal::Result<rustfs_heal::heal::storage::DiskStatus> {
|
||||
Ok(rustfs_heal::heal::storage::DiskStatus::Ok)
|
||||
}
|
||||
async fn format_disk(
|
||||
&self,
|
||||
_endpoint: &crate::common::storage_compat::ecstore::disk::endpoint::Endpoint,
|
||||
) -> rustfs_heal::Result<()> {
|
||||
async fn format_disk(&self, _endpoint: &crate::common::storage_compat::Endpoint) -> rustfs_heal::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
async fn get_bucket_info(&self, _bucket: &str) -> rustfs_heal::Result<Option<rustfs_storage_api::BucketInfo>> {
|
||||
@@ -253,10 +250,7 @@ fn test_heal_task_status_atomic_update() {
|
||||
) -> rustfs_heal::Result<(Vec<String>, Option<String>, bool)> {
|
||||
Ok((vec![], None, false))
|
||||
}
|
||||
async fn get_disk_for_resume(
|
||||
&self,
|
||||
_set_disk_id: &str,
|
||||
) -> rustfs_heal::Result<crate::common::storage_compat::ecstore::disk::DiskStore> {
|
||||
async fn get_disk_for_resume(&self, _set_disk_id: &str) -> rustfs_heal::Result<crate::common::storage_compat::DiskStore> {
|
||||
Err(rustfs_heal::Error::other("Not implemented in mock"))
|
||||
}
|
||||
}
|
||||
@@ -326,17 +320,11 @@ async fn test_heal_task_transient_object_exists_skip_avoids_recreate() {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
async fn get_disk_status(
|
||||
&self,
|
||||
_endpoint: &crate::common::storage_compat::ecstore::disk::endpoint::Endpoint,
|
||||
) -> rustfs_heal::Result<DiskStatus> {
|
||||
async fn get_disk_status(&self, _endpoint: &crate::common::storage_compat::Endpoint) -> rustfs_heal::Result<DiskStatus> {
|
||||
Ok(DiskStatus::Ok)
|
||||
}
|
||||
|
||||
async fn format_disk(
|
||||
&self,
|
||||
_endpoint: &crate::common::storage_compat::ecstore::disk::endpoint::Endpoint,
|
||||
) -> rustfs_heal::Result<()> {
|
||||
async fn format_disk(&self, _endpoint: &crate::common::storage_compat::Endpoint) -> rustfs_heal::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -406,10 +394,7 @@ async fn test_heal_task_transient_object_exists_skip_avoids_recreate() {
|
||||
Ok((Vec::new(), None, false))
|
||||
}
|
||||
|
||||
async fn get_disk_for_resume(
|
||||
&self,
|
||||
_set_disk_id: &str,
|
||||
) -> rustfs_heal::Result<crate::common::storage_compat::ecstore::disk::DiskStore> {
|
||||
async fn get_disk_for_resume(&self, _set_disk_id: &str) -> rustfs_heal::Result<crate::common::storage_compat::DiskStore> {
|
||||
Err(rustfs_heal::Error::other("not implemented"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,8 @@
|
||||
|
||||
mod common;
|
||||
|
||||
use crate::common::storage_compat::ecstore::{
|
||||
disk::endpoint::Endpoint,
|
||||
endpoints::{EndpointServerPools, Endpoints, PoolEndpoints},
|
||||
store::ECStore,
|
||||
use crate::common::storage_compat::{
|
||||
ECStore, Endpoint, EndpointServerPools, Endpoints, PoolEndpoints, init_bucket_metadata_sys, init_local_disks,
|
||||
};
|
||||
use http::HeaderMap;
|
||||
use rustfs_common::heal_channel::{HealOpts, HealScanMode};
|
||||
@@ -124,9 +122,7 @@ async fn setup_test_env() -> (Vec<PathBuf>, Arc<ECStore>, Arc<ECStoreHealStorage
|
||||
let endpoint_pools = EndpointServerPools(vec![pool_endpoints]);
|
||||
|
||||
// format disks (only first time)
|
||||
crate::common::storage_compat::ecstore::store::init_local_disks(endpoint_pools.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
init_local_disks(endpoint_pools.clone()).await.unwrap();
|
||||
|
||||
// create ECStore with dynamic port 0 (let OS assign) or fixed 9001 if free
|
||||
let port = 9001; // for simplicity
|
||||
@@ -144,7 +140,7 @@ async fn setup_test_env() -> (Vec<PathBuf>, Arc<ECStore>, Arc<ECStoreHealStorage
|
||||
.await
|
||||
.unwrap();
|
||||
let buckets = buckets_list.into_iter().map(|v| v.name).collect();
|
||||
crate::common::storage_compat::ecstore::bucket::metadata_sys::init_bucket_metadata_sys(ecstore.clone(), buckets).await;
|
||||
init_bucket_metadata_sys(ecstore.clone(), buckets).await;
|
||||
|
||||
// Create heal storage layer
|
||||
let heal_storage = Arc::new(ECStoreHealStorage::new(ecstore.clone()));
|
||||
|
||||
@@ -12,70 +12,27 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub(crate) mod ecstore {
|
||||
#![allow(unused_imports)]
|
||||
#![allow(dead_code, unused_imports)]
|
||||
|
||||
pub(crate) mod bucket {
|
||||
pub(crate) mod lifecycle {
|
||||
pub(crate) use rustfs_ecstore::bucket::lifecycle::lifecycle::TransitionOptions;
|
||||
pub(crate) const BUCKET_LIFECYCLE_CONFIG: &str = rustfs_ecstore::bucket::metadata::BUCKET_LIFECYCLE_CONFIG;
|
||||
pub(crate) const STORAGE_FORMAT_FILE: &str = rustfs_ecstore::disk::STORAGE_FORMAT_FILE;
|
||||
|
||||
pub(crate) mod bucket_lifecycle_ops {
|
||||
pub(crate) use rustfs_ecstore::bucket::lifecycle::bucket_lifecycle_ops::{
|
||||
enqueue_transition_for_existing_objects, init_background_expiry,
|
||||
};
|
||||
}
|
||||
}
|
||||
pub(crate) type TransitionOptions = rustfs_ecstore::bucket::lifecycle::lifecycle::TransitionOptions;
|
||||
|
||||
pub(crate) mod metadata {
|
||||
pub(crate) use rustfs_ecstore::bucket::metadata::BUCKET_LIFECYCLE_CONFIG;
|
||||
}
|
||||
|
||||
pub(crate) mod metadata_sys {
|
||||
pub(crate) use rustfs_ecstore::bucket::metadata_sys::{get, init_bucket_metadata_sys, update};
|
||||
}
|
||||
|
||||
pub(crate) mod versioning_sys {
|
||||
pub(crate) use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod client {
|
||||
pub(crate) mod transition_api {
|
||||
pub(crate) use rustfs_ecstore::client::transition_api::{ReadCloser, ReaderImpl};
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod disk {
|
||||
pub(crate) use rustfs_ecstore::disk::{DiskAPI, DiskOption, STORAGE_FORMAT_FILE, new_disk};
|
||||
|
||||
pub(crate) mod endpoint {
|
||||
pub(crate) use rustfs_ecstore::disk::endpoint::Endpoint;
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) mod endpoints {
|
||||
pub(crate) use rustfs_ecstore::endpoints::{EndpointServerPools, Endpoints, PoolEndpoints};
|
||||
}
|
||||
|
||||
pub(crate) mod global {
|
||||
pub(crate) use rustfs_ecstore::global::GLOBAL_TierConfigMgr;
|
||||
}
|
||||
|
||||
pub(crate) mod pools {
|
||||
pub(crate) use rustfs_ecstore::pools::path2_bucket_object_with_base_path;
|
||||
}
|
||||
|
||||
pub(crate) mod store {
|
||||
pub(crate) use rustfs_ecstore::store::{ECStore, init_local_disks};
|
||||
}
|
||||
|
||||
pub(crate) mod tier {
|
||||
pub(crate) mod tier_config {
|
||||
pub(crate) use rustfs_ecstore::tier::tier_config::{TierConfig, TierMinIO, TierType};
|
||||
}
|
||||
|
||||
pub(crate) mod warm_backend {
|
||||
pub(crate) use rustfs_ecstore::tier::warm_backend::{WarmBackend, WarmBackendGetOpts, build_transition_put_options};
|
||||
}
|
||||
}
|
||||
}
|
||||
pub(crate) use rustfs_ecstore::bucket::lifecycle::bucket_lifecycle_ops::{
|
||||
enqueue_transition_for_existing_objects, init_background_expiry,
|
||||
};
|
||||
pub(crate) use rustfs_ecstore::bucket::metadata_sys::{
|
||||
get as get_bucket_metadata, init_bucket_metadata_sys, update as update_bucket_metadata,
|
||||
};
|
||||
pub(crate) use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys;
|
||||
pub(crate) use rustfs_ecstore::client::transition_api::{ReadCloser, ReaderImpl};
|
||||
pub(crate) use rustfs_ecstore::disk::{DiskAPI, DiskOption, endpoint::Endpoint, new_disk};
|
||||
pub(crate) use rustfs_ecstore::endpoints::{EndpointServerPools, Endpoints, PoolEndpoints};
|
||||
pub(crate) use rustfs_ecstore::global::GLOBAL_TierConfigMgr;
|
||||
pub(crate) use rustfs_ecstore::pools::path2_bucket_object_with_base_path;
|
||||
pub(crate) use rustfs_ecstore::store::ECStore;
|
||||
pub(crate) use rustfs_ecstore::store::init_local_disks;
|
||||
pub(crate) use rustfs_ecstore::tier::tier_config::{TierConfig, TierMinIO, TierType};
|
||||
pub(crate) use rustfs_ecstore::tier::warm_backend::WarmBackendGetOpts;
|
||||
pub(crate) use rustfs_ecstore::tier::warm_backend::{WarmBackend, build_transition_put_options};
|
||||
|
||||
@@ -14,24 +14,12 @@
|
||||
|
||||
mod common;
|
||||
|
||||
use crate::common::storage_compat::ecstore::{
|
||||
bucket::metadata::BUCKET_LIFECYCLE_CONFIG,
|
||||
bucket::{
|
||||
lifecycle::{TransitionOptions, bucket_lifecycle_ops::enqueue_transition_for_existing_objects},
|
||||
metadata_sys,
|
||||
versioning_sys::BucketVersioningSys,
|
||||
},
|
||||
client::transition_api::{ReadCloser, ReaderImpl},
|
||||
disk::endpoint::Endpoint,
|
||||
disk::{DiskAPI, DiskOption, STORAGE_FORMAT_FILE, new_disk},
|
||||
endpoints::{EndpointServerPools, Endpoints, PoolEndpoints},
|
||||
global::GLOBAL_TierConfigMgr,
|
||||
pools::path2_bucket_object_with_base_path,
|
||||
store::ECStore,
|
||||
tier::{
|
||||
tier_config::{TierConfig, TierMinIO, TierType},
|
||||
warm_backend::{WarmBackend, WarmBackendGetOpts, build_transition_put_options},
|
||||
},
|
||||
use crate::common::storage_compat::{
|
||||
BUCKET_LIFECYCLE_CONFIG, BucketVersioningSys, DiskAPI, DiskOption, ECStore, Endpoint, EndpointServerPools, Endpoints,
|
||||
GLOBAL_TierConfigMgr, PoolEndpoints, ReadCloser, ReaderImpl, STORAGE_FORMAT_FILE, TierConfig, TierMinIO, TierType,
|
||||
TransitionOptions, WarmBackend, WarmBackendGetOpts, build_transition_put_options, enqueue_transition_for_existing_objects,
|
||||
get_bucket_metadata, init_background_expiry, init_bucket_metadata_sys, init_local_disks, new_disk,
|
||||
path2_bucket_object_with_base_path, update_bucket_metadata,
|
||||
};
|
||||
use futures::FutureExt;
|
||||
use rustfs_config::ENV_TEST_FORCE_IMMEDIATE_TRANSITION_ENQUEUE_TIMEOUT;
|
||||
@@ -125,9 +113,7 @@ async fn setup_test_env() -> (Vec<PathBuf>, Arc<ECStore>) {
|
||||
let endpoint_pools = EndpointServerPools(vec![pool_endpoints]);
|
||||
|
||||
// format disks (only first time)
|
||||
crate::common::storage_compat::ecstore::store::init_local_disks(endpoint_pools.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
init_local_disks(endpoint_pools.clone()).await.unwrap();
|
||||
|
||||
// create ECStore with dynamic port 0 (let OS assign) or fixed 9002 if free
|
||||
let port = 9002; // for simplicity
|
||||
@@ -145,11 +131,10 @@ async fn setup_test_env() -> (Vec<PathBuf>, Arc<ECStore>) {
|
||||
.await
|
||||
.unwrap();
|
||||
let buckets = buckets_list.into_iter().map(|v| v.name).collect();
|
||||
crate::common::storage_compat::ecstore::bucket::metadata_sys::init_bucket_metadata_sys(ecstore.clone(), buckets).await;
|
||||
init_bucket_metadata_sys(ecstore.clone(), buckets).await;
|
||||
|
||||
// Initialize background expiry workers
|
||||
crate::common::storage_compat::ecstore::bucket::lifecycle::bucket_lifecycle_ops::init_background_expiry(ecstore.clone())
|
||||
.await;
|
||||
init_background_expiry(ecstore.clone()).await;
|
||||
|
||||
// Store in global once lock
|
||||
let _ = GLOBAL_ENV.set((disk_paths.clone(), ecstore.clone()));
|
||||
@@ -197,9 +182,7 @@ async fn setup_isolated_test_env(init_expiry: bool) -> (Vec<PathBuf>, Arc<ECStor
|
||||
};
|
||||
|
||||
let endpoint_pools = EndpointServerPools(vec![pool_endpoints]);
|
||||
crate::common::storage_compat::ecstore::store::init_local_disks(endpoint_pools.clone())
|
||||
.await
|
||||
.unwrap();
|
||||
init_local_disks(endpoint_pools.clone()).await.unwrap();
|
||||
|
||||
let server_addr: std::net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||
let ecstore = ECStore::new(server_addr, endpoint_pools, CancellationToken::new())
|
||||
@@ -214,11 +197,10 @@ async fn setup_isolated_test_env(init_expiry: bool) -> (Vec<PathBuf>, Arc<ECStor
|
||||
.await
|
||||
.unwrap();
|
||||
let buckets = buckets_list.into_iter().map(|v| v.name).collect();
|
||||
crate::common::storage_compat::ecstore::bucket::metadata_sys::init_bucket_metadata_sys(ecstore.clone(), buckets).await;
|
||||
init_bucket_metadata_sys(ecstore.clone(), buckets).await;
|
||||
|
||||
if init_expiry {
|
||||
crate::common::storage_compat::ecstore::bucket::lifecycle::bucket_lifecycle_ops::init_background_expiry(ecstore.clone())
|
||||
.await;
|
||||
init_background_expiry(ecstore.clone()).await;
|
||||
}
|
||||
|
||||
(disk_paths, ecstore)
|
||||
@@ -287,7 +269,7 @@ async fn set_bucket_lifecycle(bucket_name: &str) -> Result<(), Box<dyn std::erro
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#;
|
||||
|
||||
metadata_sys::update(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec()).await?;
|
||||
update_bucket_metadata(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -311,7 +293,7 @@ async fn set_bucket_lifecycle_deletemarker(bucket_name: &str) -> Result<(), Box<
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#;
|
||||
|
||||
metadata_sys::update(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec()).await?;
|
||||
update_bucket_metadata(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -334,7 +316,7 @@ async fn set_bucket_lifecycle_delmarker_expiration(bucket_name: &str, days: i64)
|
||||
</LifecycleConfiguration>"#
|
||||
);
|
||||
|
||||
metadata_sys::update(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes()).await?;
|
||||
update_bucket_metadata(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -378,7 +360,7 @@ async fn set_bucket_lifecycle_transition_with_tier(
|
||||
</LifecycleConfiguration>"#
|
||||
);
|
||||
|
||||
metadata_sys::update(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes()).await?;
|
||||
update_bucket_metadata(bucket_name, BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes()).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -613,7 +595,7 @@ async fn scan_object_with_lifecycle(disk_path: &Path, bucket: &str, object: &str
|
||||
.await
|
||||
.expect("failed to stat object metadata")
|
||||
.file_type();
|
||||
let lifecycle = metadata_sys::get(bucket)
|
||||
let lifecycle = get_bucket_metadata(bucket)
|
||||
.await
|
||||
.expect("failed to load bucket metadata")
|
||||
.lifecycle_config
|
||||
@@ -878,7 +860,7 @@ mod serial_tests {
|
||||
println!("✅ Lifecycle configuration set for bucket: {bucket_name}");
|
||||
|
||||
// Verify lifecycle configuration was set
|
||||
match crate::common::storage_compat::ecstore::bucket::metadata_sys::get(bucket_name.as_str()).await {
|
||||
match get_bucket_metadata(bucket_name.as_str()).await {
|
||||
Ok(bucket_meta) => {
|
||||
assert!(bucket_meta.lifecycle_config.is_some());
|
||||
println!("✅ Bucket metadata retrieved successfully");
|
||||
@@ -1284,8 +1266,7 @@ mod serial_tests {
|
||||
"stale transitioned remote object should still exist before scanner fallback runs"
|
||||
);
|
||||
|
||||
crate::common::storage_compat::ecstore::bucket::lifecycle::bucket_lifecycle_ops::init_background_expiry(ecstore.clone())
|
||||
.await;
|
||||
init_background_expiry(ecstore.clone()).await;
|
||||
scan_object_metadata(&disk_paths[0], bucket_name.as_str(), object_name).await;
|
||||
|
||||
assert!(
|
||||
@@ -1346,8 +1327,7 @@ mod serial_tests {
|
||||
"stale transitioned remote object should still exist before scanner cleanup runs"
|
||||
);
|
||||
|
||||
crate::common::storage_compat::ecstore::bucket::lifecycle::bucket_lifecycle_ops::init_background_expiry(ecstore.clone())
|
||||
.await;
|
||||
init_background_expiry(ecstore.clone()).await;
|
||||
scan_object_metadata(&disk_paths[0], bucket_name.as_str(), object_name).await;
|
||||
|
||||
assert!(
|
||||
@@ -1437,7 +1417,7 @@ mod serial_tests {
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#
|
||||
);
|
||||
metadata_sys::update(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
update_bucket_metadata(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
.await
|
||||
.expect("Failed to set lifecycle configuration");
|
||||
|
||||
@@ -1522,7 +1502,7 @@ mod serial_tests {
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#
|
||||
);
|
||||
metadata_sys::update(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
update_bucket_metadata(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
.await
|
||||
.expect("Failed to set lifecycle configuration");
|
||||
|
||||
@@ -1714,8 +1694,7 @@ mod serial_tests {
|
||||
|
||||
assert!(object_exists(&ecstore, bucket_name.as_str(), object_name).await);
|
||||
|
||||
crate::common::storage_compat::ecstore::bucket::lifecycle::bucket_lifecycle_ops::init_background_expiry(ecstore.clone())
|
||||
.await;
|
||||
init_background_expiry(ecstore.clone()).await;
|
||||
scan_object_with_lifecycle(&disk_paths[0], bucket_name.as_str(), object_name).await;
|
||||
|
||||
assert!(
|
||||
@@ -1750,7 +1729,7 @@ mod serial_tests {
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#
|
||||
);
|
||||
metadata_sys::update(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
update_bucket_metadata(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
.await
|
||||
.expect("Failed to set lifecycle configuration");
|
||||
|
||||
@@ -1815,12 +1794,11 @@ mod serial_tests {
|
||||
</NoncurrentVersionExpiration>
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#;
|
||||
metadata_sys::update(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec())
|
||||
update_bucket_metadata(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec())
|
||||
.await
|
||||
.expect("Failed to set noncurrent lifecycle configuration");
|
||||
|
||||
crate::common::storage_compat::ecstore::bucket::lifecycle::bucket_lifecycle_ops::init_background_expiry(ecstore.clone())
|
||||
.await;
|
||||
init_background_expiry(ecstore.clone()).await;
|
||||
|
||||
scan_object_with_lifecycle(&disk_paths[0], bucket_name.as_str(), object_name).await;
|
||||
|
||||
@@ -1854,7 +1832,7 @@ mod serial_tests {
|
||||
</NoncurrentVersionExpiration>
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#;
|
||||
metadata_sys::update(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec())
|
||||
update_bucket_metadata(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.as_bytes().to_vec())
|
||||
.await
|
||||
.expect("Failed to set noncurrent lifecycle configuration");
|
||||
|
||||
@@ -1941,7 +1919,7 @@ mod serial_tests {
|
||||
</Rule>
|
||||
</LifecycleConfiguration>"#
|
||||
);
|
||||
metadata_sys::update(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
update_bucket_metadata(bucket_name.as_str(), BUCKET_LIFECYCLE_CONFIG, lifecycle_xml.into_bytes())
|
||||
.await
|
||||
.expect("Failed to set lifecycle configuration");
|
||||
upload_test_object(&ecstore, bucket_name.as_str(), object_name, b"expire immediately").await;
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum CapabilityState {
|
||||
Supported,
|
||||
Unsupported,
|
||||
Disabled,
|
||||
#[default]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl CapabilityState {
|
||||
pub const fn is_supported(self) -> bool {
|
||||
matches!(self, Self::Supported)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct CapabilityStatus {
|
||||
pub state: CapabilityState,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reason: Option<String>,
|
||||
}
|
||||
|
||||
impl CapabilityStatus {
|
||||
pub const fn new(state: CapabilityState) -> Self {
|
||||
Self { state, reason: None }
|
||||
}
|
||||
|
||||
pub const fn supported() -> Self {
|
||||
Self::new(CapabilityState::Supported)
|
||||
}
|
||||
|
||||
pub const fn unsupported() -> Self {
|
||||
Self::new(CapabilityState::Unsupported)
|
||||
}
|
||||
|
||||
pub const fn disabled() -> Self {
|
||||
Self::new(CapabilityState::Disabled)
|
||||
}
|
||||
|
||||
pub const fn unknown() -> Self {
|
||||
Self::new(CapabilityState::Unknown)
|
||||
}
|
||||
|
||||
pub fn with_reason(mut self, reason: impl Into<String>) -> Self {
|
||||
self.reason = Some(reason.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CapabilityStatus {
|
||||
fn default() -> Self {
|
||||
Self::unknown()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum CapabilitySnapshotError {
|
||||
Unavailable,
|
||||
Unsupported,
|
||||
InvalidSnapshot(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for CapabilitySnapshotError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Unavailable => f.write_str("capability snapshot unavailable"),
|
||||
Self::Unsupported => f.write_str("capability snapshot unsupported"),
|
||||
Self::InvalidSnapshot(reason) => write!(f, "invalid capability snapshot: {reason}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for CapabilitySnapshotError {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn capability_status_serializes_unknown_and_unsupported_states() {
|
||||
let unknown = CapabilityStatus::unknown();
|
||||
let unsupported = CapabilityStatus::unsupported().with_reason("target does not expose profiler");
|
||||
|
||||
let encoded = serde_json::to_string(&(unknown, unsupported)).expect("serialize capability statuses");
|
||||
let decoded: (CapabilityStatus, CapabilityStatus) =
|
||||
serde_json::from_str(&encoded).expect("deserialize capability statuses");
|
||||
|
||||
assert_eq!(decoded.0.state, CapabilityState::Unknown);
|
||||
assert_eq!(decoded.1.state, CapabilityState::Unsupported);
|
||||
assert_eq!(decoded.1.reason.as_deref(), Some("target does not expose profiler"));
|
||||
assert!(!decoded.1.state.is_supported());
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,16 @@
|
||||
|
||||
pub mod admin;
|
||||
pub mod bucket;
|
||||
pub mod capability;
|
||||
pub mod error;
|
||||
pub mod multipart;
|
||||
pub mod object;
|
||||
pub mod observability;
|
||||
pub mod topology;
|
||||
|
||||
pub use admin::{DiskSetSelector, StorageAdminApi};
|
||||
pub use bucket::{BucketInfo, BucketOperations, BucketOptions, DeleteBucketOptions, MakeBucketOptions, SRBucketDeleteOp};
|
||||
pub use capability::{CapabilitySnapshotError, CapabilityState, CapabilityStatus};
|
||||
pub use error::{StorageErrorCode, StorageResult};
|
||||
pub use multipart::{CompletePart, ListMultipartsInfo, ListPartsInfo, MultipartInfo, MultipartUploadResult, PartInfo};
|
||||
pub use object::{DeletedObject, ObjectToDelete};
|
||||
@@ -31,3 +35,10 @@ pub use object::{HealOperations, MultipartOperations, NamespaceLocking, ObjectIO
|
||||
pub use object::{ListObjectVersionsInfo, ListObjectsInfo, ListObjectsV2Info, ListOperations, ObjectInfoOrErr};
|
||||
pub use object::{ObjectPreconditionError, ObjectPreconditionPart, ObjectPreconditionState};
|
||||
pub use object::{VersionMarker, WalkOptions, WalkVersionsSortOrder};
|
||||
pub use observability::{
|
||||
MemorySamplingState, ObservabilitySnapshot, ObservabilitySnapshotProvider, PlatformSupport, UserspaceProfilingCapability,
|
||||
};
|
||||
pub use topology::{
|
||||
DiskCapabilities, TopologyCapabilities, TopologyDisk, TopologyLabels, TopologyPool, TopologySet, TopologySnapshot,
|
||||
TopologySnapshotProvider,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{CapabilitySnapshotError, CapabilityStatus};
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ObservabilitySnapshot {
|
||||
pub runtime_telemetry: CapabilityStatus,
|
||||
pub userspace_profiling: UserspaceProfilingCapability,
|
||||
pub memory_sampling: MemorySamplingState,
|
||||
pub platform: PlatformSupport,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct UserspaceProfilingCapability {
|
||||
pub cpu: CapabilityStatus,
|
||||
pub memory: CapabilityStatus,
|
||||
pub continuous_cpu: CapabilityStatus,
|
||||
pub periodic_cpu: CapabilityStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct MemorySamplingState {
|
||||
pub process: CapabilityStatus,
|
||||
pub system: CapabilityStatus,
|
||||
pub cgroup: CapabilityStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct PlatformSupport {
|
||||
pub target_triple: Option<String>,
|
||||
pub os: Option<String>,
|
||||
pub arch: Option<String>,
|
||||
pub allocator: CapabilityStatus,
|
||||
pub ebpf: CapabilityStatus,
|
||||
pub numa: CapabilityStatus,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait ObservabilitySnapshotProvider: Send + Sync + Debug {
|
||||
async fn observability_snapshot(&self) -> Result<ObservabilitySnapshot, CapabilitySnapshotError>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::CapabilityState;
|
||||
|
||||
#[test]
|
||||
fn observability_snapshot_preserves_unknown_and_unsupported_states() {
|
||||
let snapshot = ObservabilitySnapshot {
|
||||
runtime_telemetry: CapabilityStatus::unknown(),
|
||||
userspace_profiling: UserspaceProfilingCapability {
|
||||
cpu: CapabilityStatus::unsupported().with_reason("unsupported target"),
|
||||
memory: CapabilityStatus::disabled(),
|
||||
continuous_cpu: CapabilityStatus::unknown(),
|
||||
periodic_cpu: CapabilityStatus::supported(),
|
||||
},
|
||||
memory_sampling: MemorySamplingState {
|
||||
process: CapabilityStatus::supported(),
|
||||
system: CapabilityStatus::supported(),
|
||||
cgroup: CapabilityStatus::unknown(),
|
||||
},
|
||||
platform: PlatformSupport {
|
||||
target_triple: Some("x86_64-unknown-linux-gnu".to_owned()),
|
||||
os: Some("linux".to_owned()),
|
||||
arch: Some("x86_64".to_owned()),
|
||||
allocator: CapabilityStatus::supported(),
|
||||
ebpf: CapabilityStatus::unknown(),
|
||||
numa: CapabilityStatus::unsupported(),
|
||||
},
|
||||
};
|
||||
|
||||
let encoded = serde_json::to_string(&snapshot).expect("serialize observability snapshot");
|
||||
let decoded: ObservabilitySnapshot = serde_json::from_str(&encoded).expect("deserialize observability snapshot");
|
||||
|
||||
assert_eq!(decoded.runtime_telemetry.state, CapabilityState::Unknown);
|
||||
assert_eq!(decoded.userspace_profiling.cpu.state, CapabilityState::Unsupported);
|
||||
assert_eq!(decoded.userspace_profiling.memory.state, CapabilityState::Disabled);
|
||||
assert_eq!(decoded.platform.numa.state, CapabilityState::Unsupported);
|
||||
assert_eq!(decoded.platform.ebpf.state, CapabilityState::Unknown);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
// Copyright 2024 RustFS Team
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{CapabilitySnapshotError, CapabilityStatus};
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct TopologySnapshot {
|
||||
pub pools: Vec<TopologyPool>,
|
||||
pub capabilities: TopologyCapabilities,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct TopologyCapabilities {
|
||||
pub profiling: CapabilityStatus,
|
||||
pub numa: CapabilityStatus,
|
||||
pub failure_domain_labels: CapabilityStatus,
|
||||
pub media_labels: CapabilityStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct TopologyPool {
|
||||
pub pool_index: usize,
|
||||
pub pool_id: Option<String>,
|
||||
pub labels: TopologyLabels,
|
||||
pub sets: Vec<TopologySet>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct TopologySet {
|
||||
pub pool_index: usize,
|
||||
pub set_index: usize,
|
||||
pub set_id: Option<String>,
|
||||
pub labels: TopologyLabels,
|
||||
pub disks: Vec<TopologyDisk>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct TopologyDisk {
|
||||
pub pool_index: usize,
|
||||
pub set_index: usize,
|
||||
pub disk_index: usize,
|
||||
pub disk_id: Option<String>,
|
||||
pub labels: TopologyLabels,
|
||||
pub capabilities: DiskCapabilities,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct TopologyLabels {
|
||||
pub zone: Option<String>,
|
||||
pub rack: Option<String>,
|
||||
pub node: Option<String>,
|
||||
pub media: Option<String>,
|
||||
pub numa_node: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub additional: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct DiskCapabilities {
|
||||
pub media_type: CapabilityStatus,
|
||||
pub failure_domain: CapabilityStatus,
|
||||
pub numa: CapabilityStatus,
|
||||
pub profiling: CapabilityStatus,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait TopologySnapshotProvider: Send + Sync + Debug {
|
||||
async fn topology_snapshot(&self) -> Result<TopologySnapshot, CapabilitySnapshotError>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::CapabilityState;
|
||||
|
||||
#[test]
|
||||
fn topology_snapshot_allows_missing_and_extra_labels() {
|
||||
let raw = r#"{
|
||||
"pools": [{
|
||||
"pool_index": 0,
|
||||
"pool_id": null,
|
||||
"labels": {
|
||||
"additional": {
|
||||
"room": "a"
|
||||
}
|
||||
},
|
||||
"sets": [{
|
||||
"pool_index": 0,
|
||||
"set_index": 1,
|
||||
"set_id": null,
|
||||
"labels": {},
|
||||
"disks": [{
|
||||
"pool_index": 0,
|
||||
"set_index": 1,
|
||||
"disk_index": 2,
|
||||
"disk_id": "disk-2",
|
||||
"labels": {
|
||||
"media": "ssd",
|
||||
"additional": {
|
||||
"slot": "nvme0"
|
||||
}
|
||||
},
|
||||
"capabilities": {
|
||||
"media_type": { "state": "supported" },
|
||||
"failure_domain": { "state": "unknown" },
|
||||
"numa": { "state": "unsupported", "reason": "not reported" },
|
||||
"profiling": { "state": "disabled" }
|
||||
}
|
||||
}]
|
||||
}]
|
||||
}],
|
||||
"capabilities": {
|
||||
"profiling": { "state": "supported" },
|
||||
"numa": { "state": "unknown" },
|
||||
"failure_domain_labels": { "state": "supported" },
|
||||
"media_labels": { "state": "supported" }
|
||||
}
|
||||
}"#;
|
||||
|
||||
let snapshot: TopologySnapshot = serde_json::from_str(raw).expect("deserialize topology snapshot");
|
||||
let disk = &snapshot.pools[0].sets[0].disks[0];
|
||||
|
||||
assert_eq!(snapshot.pools[0].labels.zone, None);
|
||||
assert_eq!(snapshot.pools[0].labels.additional.get("room").map(String::as_str), Some("a"));
|
||||
assert_eq!(disk.labels.media.as_deref(), Some("ssd"));
|
||||
assert_eq!(disk.labels.additional.get("slot").map(String::as_str), Some("nvme0"));
|
||||
assert_eq!(disk.capabilities.numa.state, CapabilityState::Unsupported);
|
||||
assert_eq!(disk.capabilities.profiling.state, CapabilityState::Disabled);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user