diff --git a/crates/ecstore/src/bucket/replication/replication_pool.rs b/crates/ecstore/src/bucket/replication/replication_pool.rs index 0a8e41bae..38bbd9514 100644 --- a/crates/ecstore/src/bucket/replication/replication_pool.rs +++ b/crates/ecstore/src/bucket/replication/replication_pool.rs @@ -977,6 +977,10 @@ pub async fn init_background_replication(storage: Arc) { assert!(GLOBAL_REPLICATION_POOL.get().is_some()); } +pub fn get_global_replication_pool() -> Option> { + GLOBAL_REPLICATION_POOL.get().cloned() +} + pub async fn schedule_replication(oi: ObjectInfo, o: Arc, dsc: ReplicateDecision, op_type: ReplicationType) { let tgt_statuses = replication_statuses_map(&oi.replication_status_internal.clone().unwrap_or_default()); let purge_statuses = version_purge_statuses_map(&oi.version_purge_status_internal.clone().unwrap_or_default()); diff --git a/crates/ecstore/src/config/mod.rs b/crates/ecstore/src/config/mod.rs index a7e67c49a..ab31b2515 100644 --- a/crates/ecstore/src/config/mod.rs +++ b/crates/ecstore/src/config/mod.rs @@ -71,6 +71,10 @@ pub fn get_global_server_config() -> Option { GLOBAL_SERVER_CONFIG.get().cloned() } +pub async fn init_global_config_sys(api: Arc) -> Result<()> { + GLOBAL_CONFIG_SYS.init(api).await +} + #[derive(Debug, Deserialize, Serialize, Clone)] pub struct KV { pub key: String, diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index da001aa3c..d0cc7a1cf 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -47,9 +47,8 @@ use rustfs_ecstore::store::init_lock_clients; use rustfs_ecstore::{ StorageAPI, bucket::metadata_sys::init_bucket_metadata_sys, - bucket::replication::{GLOBAL_REPLICATION_POOL, init_background_replication}, + bucket::replication::{get_global_replication_pool, init_background_replication}, config as ecconfig, - config::GLOBAL_CONFIG_SYS, endpoints::EndpointServerPools, global::{set_global_rustfs_port, shutdown_background_services}, notification_sys::new_global_notification_sys, @@ -278,12 +277,12 @@ async fn run(config: config::Config) -> Result<()> { // // Initialize global configuration system let mut retry_count = 0; - while let Err(e) = GLOBAL_CONFIG_SYS.init(store.clone()).await { - error!("GLOBAL_CONFIG_SYS.init failed {:?}", e); + while let Err(e) = ecconfig::init_global_config_sys(store.clone()).await { + error!("ecconfig::init_global_config_sys failed {:?}", e); // TODO: check error type retry_count += 1; if retry_count > 15 { - return Err(Error::other("GLOBAL_CONFIG_SYS.init failed")); + return Err(Error::other("ecconfig::init_global_config_sys failed")); } tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; } @@ -355,8 +354,8 @@ async fn run(config: config::Config) -> Result<()> { // Collect bucket names into a vector let buckets: Vec = buckets_list.into_iter().map(|v| v.name).collect(); - if let Some(pool) = GLOBAL_REPLICATION_POOL.get() { - pool.clone().init_resync(ctx.clone(), buckets.clone()).await?; + if let Some(pool) = get_global_replication_pool() { + pool.init_resync(ctx.clone(), buckets.clone()).await?; } init_bucket_metadata_sys(store.clone(), buckets.clone()).await;