aboutsummaryrefslogtreecommitdiff
path: root/src/garage/cli/layout.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-11-08 14:23:08 +0100
committerAlex Auvolat <alex@adnab.me>2022-11-08 14:58:39 +0100
commitd75b37b018fc0ce8e3832c8531d9556ff7a345c9 (patch)
treebb458446bd8bc8c098beedbebbd4cbefb7359724 /src/garage/cli/layout.rs
parent73a4ca8b1515f95bf7860fc292c12db83d3c6228 (diff)
downloadgarage-d75b37b018fc0ce8e3832c8531d9556ff7a345c9.tar.gz
garage-d75b37b018fc0ce8e3832c8531d9556ff7a345c9.zip
Return more info when layout's .check() fails, fix compilation, fix test
Diffstat (limited to 'src/garage/cli/layout.rs')
-rw-r--r--src/garage/cli/layout.rs32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/garage/cli/layout.rs b/src/garage/cli/layout.rs
index 85af345a..53430e6b 100644
--- a/src/garage/cli/layout.rs
+++ b/src/garage/cli/layout.rs
@@ -330,7 +330,7 @@ pub async fn send_layout(
}
pub fn print_cluster_layout(layout: &ClusterLayout) -> bool {
- let mut table = vec!["ID\tTags\tZone\tCapacity\tUsable".to_string()];
+ let mut table = vec!["ID\tTags\tZone\tCapacity\tUsable capacity".to_string()];
for (id, _, role) in layout.roles.items().iter() {
let role = match &role.0 {
Some(r) => r,
@@ -338,16 +338,26 @@ pub fn print_cluster_layout(layout: &ClusterLayout) -> bool {
};
let tags = role.tags.join(",");
let usage = layout.get_node_usage(id).unwrap_or(0);
- let capacity = layout.get_node_capacity(id).unwrap_or(1);
- table.push(format!(
- "{:?}\t{}\t{}\t{}\t{} ({:.1}%)",
- id,
- tags,
- role.zone,
- role.capacity_string(),
- ByteSize::b(usage as u64 * layout.partition_size).to_string_as(false),
- (100.0 * usage as f32 * layout.partition_size as f32) / (capacity as f32)
- ));
+ let capacity = layout.get_node_capacity(id).unwrap_or(0);
+ if capacity > 0 {
+ table.push(format!(
+ "{:?}\t{}\t{}\t{}\t{} ({:.1}%)",
+ id,
+ tags,
+ role.zone,
+ role.capacity_string(),
+ ByteSize::b(usage as u64 * layout.partition_size).to_string_as(false),
+ (100.0 * usage as f32 * layout.partition_size as f32) / (capacity as f32)
+ ));
+ } else {
+ table.push(format!(
+ "{:?}\t{}\t{}\t{}",
+ id,
+ tags,
+ role.zone,
+ role.capacity_string(),
+ ));
+ };
}
println!();
println!("Parameters of the layout computation:");