mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 21:33:14 +00:00
refactor(runtime): wrap local node name global (#4041)
This commit is contained in:
@@ -42,7 +42,6 @@ use crate::{
|
||||
services::tier::tier::TierConfigMgr,
|
||||
store::ECStore,
|
||||
};
|
||||
use rustfs_common::GLOBAL_LOCAL_NODE_NAME;
|
||||
use rustfs_concurrency::WorkloadAdmissionSnapshotProvider;
|
||||
use rustfs_config::server_config::{Config, get_global_server_config, set_global_server_config};
|
||||
use rustfs_io_metrics::internode_metrics::global_internode_metrics;
|
||||
@@ -164,11 +163,11 @@ pub(crate) async fn set_setup_type(setup_type: SetupType) {
|
||||
}
|
||||
|
||||
pub(crate) async fn local_node_name() -> String {
|
||||
GLOBAL_LOCAL_NODE_NAME.read().await.clone()
|
||||
rustfs_common::get_global_local_node_name().await
|
||||
}
|
||||
|
||||
pub(crate) async fn set_local_node_name(node_name: String) {
|
||||
*GLOBAL_LOCAL_NODE_NAME.write().await = node_name;
|
||||
rustfs_common::set_global_local_node_name(&node_name).await;
|
||||
}
|
||||
|
||||
pub(crate) fn default_local_node_name() -> String {
|
||||
@@ -510,7 +509,7 @@ pub(crate) async fn init_tier_config_mgr(store: Arc<ECStore>) -> Result<()> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::LockRegistry;
|
||||
use super::{LockRegistry, local_node_name, set_local_node_name};
|
||||
use crate::disk::endpoint::Endpoint;
|
||||
use rustfs_lock::{LocalClient, LockClient};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
@@ -546,4 +545,17 @@ mod tests {
|
||||
assert!(Arc::ptr_eq(&clients[0], &client_a));
|
||||
assert!(Arc::ptr_eq(&clients[1], &client_b));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial_test::serial]
|
||||
async fn local_node_name_round_trips_through_common_runtime_helper() {
|
||||
let previous = local_node_name().await;
|
||||
let next = "runtime-source-local-node-test".to_string();
|
||||
|
||||
set_local_node_name(next.clone()).await;
|
||||
let observed = local_node_name().await;
|
||||
set_local_node_name(previous).await;
|
||||
|
||||
assert_eq!(observed, next);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ migration PR removes or replaces each item.
|
||||
| `GLOBAL_EventNotifier`, `GLOBAL_NotificationSys` | `crates/ecstore/src/services/*` | Runtime migration target | Preserve notification and audit side effects; move only through notify/runtime-source boundaries. |
|
||||
| `GLOBAL_BOOT_TIME`, `globalDeploymentIDPtr`, `GLOBAL_REGION`, `GLOBAL_RUSTFS_PORT`, `GLOBAL_LocalNodeName` | `crates/ecstore/src/runtime/global.rs` | Runtime migration target | Scalar handles may migrate in small PRs after call sites use AppContext or owner-local runtime-source readers. |
|
||||
| `GLOBAL_LOCAL_LOCK_CLIENT`, `GLOBAL_LOCK_CLIENTS`, `GLOBAL_LOCK_MANAGER` | `crates/ecstore/src/runtime/global.rs`, `crates/lock` | Runtime migration target / process-global split | Preserve lock quorum and lock client selection; keep process-level lock manager separate from ECStore endpoint-specific clients. |
|
||||
| `GLOBAL_CONN_MAP`, `GLOBAL_RUSTFS_HOST`, `GLOBAL_RUSTFS_ADDR`, `GLOBAL_ROOT_CERT`, `GLOBAL_MTLS_IDENTITY`, `GLOBAL_OUTBOUND_TLS_GENERATION` | `crates/common`, `crates/tls-runtime`, `crates/ecstore/src/runtime/sources.rs` | Runtime migration target / process-global split | Internode connection cache, RustFS host/address reads, and outbound TLS material reads are now owned behind `rustfs_common` helpers; migrate the remaining transport and TLS state only after internode transport and outbound TLS ownership are explicit, without changing cached channel reuse or TLS reload semantics. |
|
||||
| `GLOBAL_CONN_MAP`, `GLOBAL_LOCAL_NODE_NAME`, `GLOBAL_RUSTFS_HOST`, `GLOBAL_RUSTFS_ADDR`, `GLOBAL_ROOT_CERT`, `GLOBAL_MTLS_IDENTITY`, `GLOBAL_OUTBOUND_TLS_GENERATION` | `crates/common`, `crates/tls-runtime`, `crates/ecstore/src/runtime/sources.rs` | Runtime migration target / process-global split | Internode connection cache, common local node name, RustFS host/address reads, and outbound TLS material reads are now owned behind `rustfs_common` helpers; migrate the remaining transport and TLS state only after internode transport and outbound TLS ownership are explicit, without changing cached channel reuse or TLS reload semantics. |
|
||||
| `GLOBAL_HEAL_MANAGER`, `GLOBAL_HEAL_CHANNEL_PROCESSOR`, `GLOBAL_AHM_SERVICES_CANCEL_TOKEN` | `crates/heal` and `crates/common` | Runtime migration target | Needs heal runtime owner handles and queue tests; do not combine with ECStore disk-state movement. |
|
||||
| `AUDIT_SYSTEM`, `GLOBAL_CAPACITY_MANAGER`, `GLOBAL_BUCKET_TARGET_SYS`, `GLOBAL_PROCESSORS`, `INTERNODE_DATA_TRANSPORT`, `GLOBAL_KMS_SERVICE_MANAGER` | Owner crates | Runtime migration target / process-global split | Track as owner-specific follow-ups; each owner must decide whether AppContext, a runtime-source facade, or process-global state is the right final shape. |
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@ FUZZ_ECSTORE_COMPAT_BYPASS_HITS_FILE="${TMP_DIR}/fuzz_ecstore_compat_bypass_hits
|
||||
EXTERNAL_ECSTORE_API_BOUNDARY_HITS_FILE="${TMP_DIR}/external_ecstore_api_boundary_hits.txt"
|
||||
REPLICATION_FACADE_BYPASS_HITS_FILE="${TMP_DIR}/replication_facade_bypass_hits.txt"
|
||||
GLOBAL_CONN_MAP_BYPASS_HITS_FILE="${TMP_DIR}/global_conn_map_bypass_hits.txt"
|
||||
GLOBAL_LOCAL_NODE_NAME_BYPASS_HITS_FILE="${TMP_DIR}/global_local_node_name_bypass_hits.txt"
|
||||
GLOBAL_RUSTFS_ADDR_BYPASS_HITS_FILE="${TMP_DIR}/global_rustfs_addr_bypass_hits.txt"
|
||||
GLOBAL_OUTBOUND_TLS_BYPASS_HITS_FILE="${TMP_DIR}/global_outbound_tls_bypass_hits.txt"
|
||||
LEGACY_ECSTORE_CONFIG_MODEL_HITS_FILE="${TMP_DIR}/legacy_ecstore_config_model_hits.txt"
|
||||
@@ -2305,6 +2306,18 @@ if [[ -s "$GLOBAL_CONN_MAP_BYPASS_HITS_FILE" ]]; then
|
||||
report_failure "GLOBAL_CONN_MAP access must stay behind rustfs_common connection cache helpers: $(paste -sd '; ' "$GLOBAL_CONN_MAP_BYPASS_HITS_FILE")"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$ROOT_DIR"
|
||||
rg -n --with-filename '\bGLOBAL_LOCAL_NODE_NAME\b' \
|
||||
crates rustfs fuzz \
|
||||
--glob '*.rs' |
|
||||
rg -v '^crates/common/src/globals\.rs:' || true
|
||||
) >"$GLOBAL_LOCAL_NODE_NAME_BYPASS_HITS_FILE"
|
||||
|
||||
if [[ -s "$GLOBAL_LOCAL_NODE_NAME_BYPASS_HITS_FILE" ]]; then
|
||||
report_failure "GLOBAL_LOCAL_NODE_NAME access must stay behind rustfs_common runtime helpers: $(paste -sd '; ' "$GLOBAL_LOCAL_NODE_NAME_BYPASS_HITS_FILE")"
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$ROOT_DIR"
|
||||
rg -n --with-filename '\bGLOBAL_RUSTFS_(HOST|ADDR)\b' \
|
||||
|
||||
Reference in New Issue
Block a user