mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-30 08:49:29 +00:00
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1434
This commit is contained in:
@@ -1165,6 +1165,29 @@ pub struct LocalGetNodeInfoResponse {
|
|||||||
pub rust_version: String,
|
pub rust_version: String,
|
||||||
/// database engine used for metadata
|
/// database engine used for metadata
|
||||||
pub db_engine: String,
|
pub db_engine: String,
|
||||||
|
// FIXME for v3: remove Option<> and serde(default) for field below
|
||||||
|
// FIXME for v3: merge LocalGetNodeInfoResponse and NodeResp
|
||||||
|
/// Socket address used by other nodes to connect to this node for RPC
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
#[schema(value_type = Option<String>)]
|
||||||
|
pub addr: Option<SocketAddr>,
|
||||||
|
/// Whether this node is connected in the cluster
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub is_up: Option<bool>,
|
||||||
|
/// Role assigned to this node in the current cluster layout
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub role: Option<NodeAssignedRole>,
|
||||||
|
/// Whether this node is part of an older layout version and is draining data.
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub draining: Option<bool>,
|
||||||
|
/// Total and available space on the disk partition(s) containing the data
|
||||||
|
/// directory(ies)
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub data_partition: Option<FreeSpaceResp>,
|
||||||
|
/// Total and available space on the disk partition containing the
|
||||||
|
/// metadata directory
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub metadata_partition: Option<FreeSpaceResp>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- GetNodeStatistics ----
|
// ---- GetNodeStatistics ----
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ impl RequestHandler for LocalGetNodeInfoRequest {
|
|||||||
let sys_status = garage.system.local_status();
|
let sys_status = garage.system.local_status();
|
||||||
let hostname = sys_status.hostname.unwrap_or_default().to_string();
|
let hostname = sys_status.hostname.unwrap_or_default().to_string();
|
||||||
|
|
||||||
|
let layout = garage.system.cluster_layout();
|
||||||
|
let current_layout = layout.inner().current();
|
||||||
|
|
||||||
Ok(LocalGetNodeInfoResponse {
|
Ok(LocalGetNodeInfoResponse {
|
||||||
node_id: hex::encode(garage.system.id),
|
node_id: hex::encode(garage.system.id),
|
||||||
hostname: Some(hostname),
|
hostname: Some(hostname),
|
||||||
@@ -33,6 +36,41 @@ impl RequestHandler for LocalGetNodeInfoRequest {
|
|||||||
.map(|features| features.iter().map(ToString::to_string).collect()),
|
.map(|features| features.iter().map(ToString::to_string).collect()),
|
||||||
rust_version: garage_util::version::rust_version().to_string(),
|
rust_version: garage_util::version::rust_version().to_string(),
|
||||||
db_engine: garage.db.engine(),
|
db_engine: garage.db.engine(),
|
||||||
|
is_up: Some(true),
|
||||||
|
addr: garage
|
||||||
|
.system
|
||||||
|
.get_known_nodes()
|
||||||
|
.iter()
|
||||||
|
.find(|x| x.id == garage.system.id)
|
||||||
|
.and_then(|x| x.addr),
|
||||||
|
draining: Some(
|
||||||
|
current_layout.node_role(&garage.system.id).is_none()
|
||||||
|
&& layout
|
||||||
|
.inner()
|
||||||
|
.versions
|
||||||
|
.iter()
|
||||||
|
.filter(|x| x.version != current_layout.version)
|
||||||
|
.any(|x| x.node_role(&garage.system.id).is_some()),
|
||||||
|
),
|
||||||
|
role: current_layout
|
||||||
|
.node_role(&garage.system.id)
|
||||||
|
.map(|v| NodeAssignedRole {
|
||||||
|
zone: v.zone.clone(),
|
||||||
|
capacity: v.capacity,
|
||||||
|
tags: v.tags.clone(),
|
||||||
|
}),
|
||||||
|
data_partition: sys_status
|
||||||
|
.data_disk_avail
|
||||||
|
.map(|(avail, total)| FreeSpaceResp {
|
||||||
|
available: avail,
|
||||||
|
total,
|
||||||
|
}),
|
||||||
|
metadata_partition: sys_status
|
||||||
|
.meta_disk_avail
|
||||||
|
.map(|(avail, total)| FreeSpaceResp {
|
||||||
|
available: avail,
|
||||||
|
total,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user