mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-28 16:07:05 +00:00
feat(ecstore): implement decommission and rebalance (#2281)
Co-authored-by: weisd <im@weisd.in> Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -49,7 +49,7 @@ use crate::{
|
||||
StorageAPI,
|
||||
config::com::{CONFIG_PREFIX, read_config},
|
||||
disk::{MIGRATING_META_BUCKET, RUSTFS_META_BUCKET},
|
||||
global::{get_global_endpoints, is_first_cluster_node_local},
|
||||
global::is_first_cluster_node_local,
|
||||
store::ECStore,
|
||||
store_api::{ObjectIO as _, ObjectOptions, PutObjReader},
|
||||
};
|
||||
@@ -1006,7 +1006,7 @@ impl TierConfigMgr {
|
||||
#[tracing::instrument(level = "debug", name = "tier_save", skip(self))]
|
||||
pub async fn save(&self) -> std::result::Result<(), std::io::Error> {
|
||||
let Some(api) = new_object_layer_fn() else {
|
||||
return Err(std::io::Error::other("errServerNotInitialized"));
|
||||
return Err(tier_config_not_initialized_error("save tiering config"));
|
||||
};
|
||||
//let (pr, opts) = GLOBAL_TierConfigMgr.write().config_reader()?;
|
||||
|
||||
@@ -1231,6 +1231,10 @@ pub fn is_err_config_not_found(err: &StorageError) -> bool {
|
||||
matches!(err, StorageError::ObjectNotFound(_, _) | StorageError::BucketNotFound(_)) || err == &StorageError::ConfigNotFound
|
||||
}
|
||||
|
||||
fn tier_config_not_initialized_error(operation: &str) -> std::io::Error {
|
||||
std::io::Error::other(format!("failed to {operation}: object layer not initialized"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -1335,4 +1339,13 @@ mod tests {
|
||||
Some("bucket-a")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tier_config_not_initialized_error_formats_operation_context() {
|
||||
let err = tier_config_not_initialized_error("save tiering config");
|
||||
let rendered = err.to_string();
|
||||
|
||||
assert!(rendered.contains("failed to save tiering config"), "{rendered}");
|
||||
assert!(rendered.contains("object layer not initialized"), "{rendered}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user