mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-18 18:46:17 +00:00
fix: #331 admin info version,uptime
This commit is contained in:
Generated
+1
@@ -3090,6 +3090,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2 0.11.0-pre.5",
|
"sha2 0.11.0-pre.5",
|
||||||
|
"shadow-rs",
|
||||||
"siphasher 1.0.1",
|
"siphasher 1.0.1",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ workers.workspace = true
|
|||||||
reqwest = { workspace = true }
|
reqwest = { workspace = true }
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
smallvec = "1.15.0"
|
smallvec = "1.15.0"
|
||||||
|
shadow-rs.workspace = true
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
|
|
||||||
@@ -81,3 +82,6 @@ winapi = "0.3.9"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
|
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
shadow-rs.workspace = true
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fn main() -> shadow_rs::SdResult<()> {
|
||||||
|
shadow_rs::ShadowBuilder::builder().build()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
disk::endpoint::Endpoint,
|
disk::endpoint::Endpoint,
|
||||||
global::GLOBAL_Endpoints,
|
global::{GLOBAL_Endpoints, GLOBAL_BOOT_TIME},
|
||||||
heal::{
|
heal::{
|
||||||
data_usage::{load_data_usage_from_backend, DATA_USAGE_CACHE_NAME, DATA_USAGE_ROOT},
|
data_usage::{load_data_usage_from_backend, DATA_USAGE_CACHE_NAME, DATA_USAGE_ROOT},
|
||||||
data_usage_cache::DataUsageCache,
|
data_usage_cache::DataUsageCache,
|
||||||
@@ -22,12 +22,16 @@ use protos::{
|
|||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
time::SystemTime,
|
||||||
};
|
};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tonic::Request;
|
use tonic::Request;
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
|
use shadow_rs::shadow;
|
||||||
|
|
||||||
|
shadow!(build);
|
||||||
|
|
||||||
// pub const ITEM_OFFLINE: &str = "offline";
|
// pub const ITEM_OFFLINE: &str = "offline";
|
||||||
// pub const ITEM_INITIALIZING: &str = "initializing";
|
// pub const ITEM_INITIALIZING: &str = "initializing";
|
||||||
// pub const ITEM_ONLINE: &str = "online";
|
// pub const ITEM_ONLINE: &str = "online";
|
||||||
@@ -140,8 +144,12 @@ pub async fn get_local_server_property() -> ServerProperties {
|
|||||||
|
|
||||||
let mut props = ServerProperties {
|
let mut props = ServerProperties {
|
||||||
endpoint: addr,
|
endpoint: addr,
|
||||||
uptime: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
uptime: SystemTime::now()
|
||||||
|
.duration_since(*GLOBAL_BOOT_TIME.get().unwrap())
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_secs(),
|
||||||
network,
|
network,
|
||||||
|
version: get_commit_id(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -356,3 +364,14 @@ async fn get_pools_info(all_disks: &[Disk]) -> Result<HashMap<i32, HashMap<i32,
|
|||||||
}
|
}
|
||||||
Ok(pools_info)
|
Ok(pools_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::const_is_empty)]
|
||||||
|
pub fn get_commit_id() -> String {
|
||||||
|
if !build::TAG.is_empty() {
|
||||||
|
build::TAG.to_string()
|
||||||
|
} else if !build::SHORT_COMMIT.is_empty() {
|
||||||
|
format!("@{}", build::SHORT_COMMIT)
|
||||||
|
} else {
|
||||||
|
build::PKG_VERSION.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ use lazy_static::lazy_static;
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::{Arc, OnceLock},
|
sync::{Arc, OnceLock},
|
||||||
|
time::SystemTime,
|
||||||
};
|
};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::{OnceCell, RwLock};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::heal::mrf::MRFState;
|
use crate::heal::mrf::MRFState;
|
||||||
@@ -37,6 +38,7 @@ lazy_static! {
|
|||||||
pub static ref GLOBAL_ALlHealState: Arc<AllHealState> = AllHealState::new(false);
|
pub static ref GLOBAL_ALlHealState: Arc<AllHealState> = AllHealState::new(false);
|
||||||
pub static ref GLOBAL_MRFState: Arc<MRFState> = Arc::new(MRFState::new());
|
pub static ref GLOBAL_MRFState: Arc<MRFState> = Arc::new(MRFState::new());
|
||||||
static ref globalDeploymentIDPtr: OnceLock<Uuid> = OnceLock::new();
|
static ref globalDeploymentIDPtr: OnceLock<Uuid> = OnceLock::new();
|
||||||
|
pub static ref GLOBAL_BOOT_TIME: OnceCell<SystemTime> = OnceCell::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn global_rustfs_port() -> u16 {
|
pub fn global_rustfs_port() -> u16 {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use crate::global::get_global_endpoints;
|
use crate::admin_server_info::get_commit_id;
|
||||||
|
use crate::global::{get_global_endpoints, GLOBAL_BOOT_TIME};
|
||||||
use crate::peer_rest_client::PeerRestClient;
|
use crate::peer_rest_client::PeerRestClient;
|
||||||
use crate::StorageAPI;
|
use crate::StorageAPI;
|
||||||
use crate::{endpoints::EndpointServerPools, new_object_layer_fn};
|
use crate::{endpoints::EndpointServerPools, new_object_layer_fn};
|
||||||
@@ -7,6 +8,7 @@ use futures::future::join_all;
|
|||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use madmin::{ItemState, ServerProperties};
|
use madmin::{ItemState, ServerProperties};
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
use std::time::SystemTime;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
@@ -104,6 +106,11 @@ impl NotificationSys {
|
|||||||
match client.server_info().await {
|
match client.server_info().await {
|
||||||
Ok(info) => info,
|
Ok(info) => info,
|
||||||
Err(_) => ServerProperties {
|
Err(_) => ServerProperties {
|
||||||
|
uptime: SystemTime::now()
|
||||||
|
.duration_since(*GLOBAL_BOOT_TIME.get().unwrap())
|
||||||
|
.unwrap_or_default()
|
||||||
|
.as_secs(),
|
||||||
|
version: get_commit_id(),
|
||||||
endpoint: client.host.to_string(),
|
endpoint: client.host.to_string(),
|
||||||
state: ItemState::Offline.to_string().to_owned(),
|
state: ItemState::Offline.to_string().to_owned(),
|
||||||
disks: get_offline_disks(&client.host.to_string(), &get_global_endpoints()),
|
disks: get_offline_disks(&client.host.to_string(), &get_global_endpoints()),
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ use crate::disk::{DiskAPI, DiskInfo, DiskInfoOptions, MetaCacheEntry};
|
|||||||
use crate::error::clone_err;
|
use crate::error::clone_err;
|
||||||
use crate::global::{
|
use crate::global::{
|
||||||
get_global_endpoints, is_dist_erasure, is_erasure_sd, set_global_deployment_id, set_object_layer, DISK_ASSUME_UNKNOWN_SIZE,
|
get_global_endpoints, is_dist_erasure, is_erasure_sd, set_global_deployment_id, set_object_layer, DISK_ASSUME_UNKNOWN_SIZE,
|
||||||
DISK_FILL_FRACTION, DISK_MIN_INODES, DISK_RESERVE_FRACTION, GLOBAL_LOCAL_DISK_MAP, GLOBAL_LOCAL_DISK_SET_DRIVES,
|
DISK_FILL_FRACTION, DISK_MIN_INODES, DISK_RESERVE_FRACTION, GLOBAL_BOOT_TIME, GLOBAL_LOCAL_DISK_MAP,
|
||||||
|
GLOBAL_LOCAL_DISK_SET_DRIVES,
|
||||||
};
|
};
|
||||||
use crate::heal::data_usage::{DataUsageInfo, DATA_USAGE_ROOT};
|
use crate::heal::data_usage::{DataUsageInfo, DATA_USAGE_ROOT};
|
||||||
use crate::heal::data_usage_cache::{DataUsageCache, DataUsageCacheInfo};
|
use crate::heal::data_usage_cache::{DataUsageCache, DataUsageCacheInfo};
|
||||||
@@ -257,6 +258,8 @@ impl ECStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn init(self: &Arc<Self>) -> Result<()> {
|
pub async fn init(self: &Arc<Self>) -> Result<()> {
|
||||||
|
GLOBAL_BOOT_TIME.get_or_init(|| async { SystemTime::now() }).await;
|
||||||
|
|
||||||
if self.load_rebalance_meta().await.is_ok() {
|
if self.load_rebalance_meta().await.is_ok() {
|
||||||
self.start_rebalance().await;
|
self.start_rebalance().await;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user