mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-10 15:16:56 +00:00
refactor: centralize ecstore locality runtime sources (#3808)
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
use crate::config::{audit, notify, oidc, set_global_storage_class, storageclass};
|
||||
use crate::disk::{MIGRATING_META_BUCKET, RUSTFS_META_BUCKET};
|
||||
use crate::error::{Error, Result};
|
||||
use crate::global::is_first_cluster_node_local;
|
||||
use crate::object_api::{GetObjectReader, ObjectInfo, ObjectOptions, PutObjReader};
|
||||
use crate::runtime_sources;
|
||||
use crate::storage_api_contracts::EcstoreObjectIO;
|
||||
use http::HeaderMap;
|
||||
use rustfs_config::audit::{
|
||||
@@ -1150,7 +1150,7 @@ where
|
||||
S: EcstoreObjectIO + StorageAdminApi,
|
||||
{
|
||||
warn!("Configuration not found ({}): Start initializing new configuration", context);
|
||||
let cfg = if is_first_cluster_node_local().await {
|
||||
let cfg = if runtime_sources::first_cluster_node_is_local().await {
|
||||
new_and_save_server_config(api.clone()).await?
|
||||
} else {
|
||||
let mut cfg = new_server_config();
|
||||
|
||||
@@ -14,7 +14,7 @@ use super::{
|
||||
RebalanceBucketOutcome,
|
||||
};
|
||||
use crate::error::{Error, Result};
|
||||
use crate::global::get_global_endpoints;
|
||||
use crate::runtime_sources;
|
||||
use crate::store::ECStore;
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
@@ -120,11 +120,7 @@ impl ECStore {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !get_global_endpoints()
|
||||
.as_ref()
|
||||
.get(idx)
|
||||
.is_some_and(|v| v.endpoints.as_ref().first().is_some_and(|e| e.is_local))
|
||||
{
|
||||
if !runtime_sources::endpoint_pool_is_local(idx) {
|
||||
debug!(
|
||||
event = EVENT_REBALANCE_STATE,
|
||||
component = LOG_COMPONENT_ECSTORE,
|
||||
|
||||
@@ -28,7 +28,8 @@ use crate::{
|
||||
GLOBAL_BOOT_TIME, GLOBAL_EventNotifier, GLOBAL_IsErasureSD, GLOBAL_LOCAL_DISK_ID_MAP, GLOBAL_LOCAL_DISK_MAP,
|
||||
GLOBAL_LOCAL_DISK_SET_DRIVES, GLOBAL_LifecycleSys, GLOBAL_LocalNodeName, GLOBAL_RootDiskThreshold, GLOBAL_TierConfigMgr,
|
||||
TypeLocalDiskSetDrives, get_global_bucket_monitor, get_global_deployment_id, get_global_endpoints,
|
||||
get_global_endpoints_opt, init_global_bucket_monitor, resolve_object_store_handle, set_global_deployment_id,
|
||||
get_global_endpoints_opt, init_global_bucket_monitor, is_first_cluster_node_local, resolve_object_store_handle,
|
||||
set_global_deployment_id,
|
||||
},
|
||||
notification_sys::{NotificationSys, get_global_notification_sys},
|
||||
store::ECStore,
|
||||
@@ -58,6 +59,17 @@ pub(crate) fn endpoint_pools() -> Option<EndpointServerPools> {
|
||||
get_global_endpoints_opt()
|
||||
}
|
||||
|
||||
pub(crate) fn endpoint_pool_is_local(pool_index: usize) -> bool {
|
||||
get_global_endpoints()
|
||||
.as_ref()
|
||||
.get(pool_index)
|
||||
.is_some_and(|pool| pool.endpoints.as_ref().first().is_some_and(|endpoint| endpoint.is_local))
|
||||
}
|
||||
|
||||
pub(crate) async fn first_cluster_node_is_local() -> bool {
|
||||
is_first_cluster_node_local().await
|
||||
}
|
||||
|
||||
pub(crate) async fn local_node_name() -> String {
|
||||
GLOBAL_LOCAL_NODE_NAME.read().await.clone()
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ use crate::tier::{
|
||||
use crate::{
|
||||
config::com::{CONFIG_PREFIX, read_config},
|
||||
disk::{MIGRATING_META_BUCKET, RUSTFS_META_BUCKET},
|
||||
global::is_first_cluster_node_local,
|
||||
object_api::{GetObjectReader, ObjectInfo, ObjectOptions, PutObjReader},
|
||||
runtime_sources,
|
||||
storage_api_contracts::{EcstoreObjectIO, EcstoreObjectOperations},
|
||||
store::ECStore,
|
||||
};
|
||||
@@ -1171,7 +1171,7 @@ async fn load_tier_config(api: Arc<ECStore>) -> std::result::Result<TierConfigMg
|
||||
}
|
||||
Err(legacy_err) if is_err_config_not_found(&legacy_err) => {
|
||||
warn!("config not found, start to init");
|
||||
if is_first_cluster_node_local().await {
|
||||
if runtime_sources::first_cluster_node_is_local().await {
|
||||
new_and_save_tiering_config(api).await.map_err(io::Error::other)
|
||||
} else {
|
||||
Ok(TierConfigMgr {
|
||||
|
||||
Reference in New Issue
Block a user