diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-08 20:03:30 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-08 20:03:30 +0200 |
commit | 17e111139308ba995fb782cbd1af555920cbbb81 (patch) | |
tree | 2262f3b46bb84a21a5e7df59c19c2ca8fa444415 /src/garage/cli | |
parent | 03e811bbbfca5a2467bb24ce1500c74661234947 (diff) | |
download | garage-17e111139308ba995fb782cbd1af555920cbbb81.tar.gz garage-17e111139308ba995fb782cbd1af555920cbbb81.zip |
First iteration of bucket object counters
Diffstat (limited to 'src/garage/cli')
-rw-r--r-- | src/garage/cli/cmd.rs | 8 | ||||
-rw-r--r-- | src/garage/cli/structs.rs | 3 | ||||
-rw-r--r-- | src/garage/cli/util.rs | 26 |
3 files changed, 34 insertions, 3 deletions
diff --git a/src/garage/cli/cmd.rs b/src/garage/cli/cmd.rs index b2dd8f14..3a0bd956 100644 --- a/src/garage/cli/cmd.rs +++ b/src/garage/cli/cmd.rs @@ -169,8 +169,12 @@ pub async fn cmd_admin( AdminRpc::BucketList(bl) => { print_bucket_list(bl); } - AdminRpc::BucketInfo(bucket, rk) => { - print_bucket_info(&bucket, &rk); + AdminRpc::BucketInfo { + bucket, + relevant_keys, + counters, + } => { + print_bucket_info(&bucket, &relevant_keys, &counters); } AdminRpc::KeyList(kl) => { print_key_list(kl); diff --git a/src/garage/cli/structs.rs b/src/garage/cli/structs.rs index 575ac857..cdaa09be 100644 --- a/src/garage/cli/structs.rs +++ b/src/garage/cli/structs.rs @@ -425,6 +425,9 @@ pub enum OfflineRepairWhat { /// Repair K2V item counters #[structopt(name = "k2v_item_counters")] K2VItemCounters, + /// Repair object counters + #[structopt(name = "object_counters")] + ObjectCounters, } #[derive(Serialize, Deserialize, StructOpt, Debug, Clone)] diff --git a/src/garage/cli/util.rs b/src/garage/cli/util.rs index 6d73be3a..23c669b9 100644 --- a/src/garage/cli/util.rs +++ b/src/garage/cli/util.rs @@ -7,6 +7,7 @@ use garage_util::formater::format_table; use garage_model::bucket_table::*; use garage_model::key_table::*; +use garage_model::s3::object_table::{BYTES, OBJECTS, UNFINISHED_UPLOADS}; pub fn print_bucket_list(bl: Vec<Bucket>) { println!("List of buckets:"); @@ -121,7 +122,11 @@ pub fn print_key_info(key: &Key, relevant_buckets: &HashMap<Uuid, Bucket>) { } } -pub fn print_bucket_info(bucket: &Bucket, relevant_keys: &HashMap<String, Key>) { +pub fn print_bucket_info( + bucket: &Bucket, + relevant_keys: &HashMap<String, Key>, + counters: &HashMap<String, i64>, +) { let key_name = |k| { relevant_keys .get(k) @@ -133,6 +138,25 @@ pub fn print_bucket_info(bucket: &Bucket, relevant_keys: &HashMap<String, Key>) match &bucket.state { Deletable::Deleted => println!("Bucket is deleted."), Deletable::Present(p) => { + let size = + bytesize::ByteSize::b(counters.get(BYTES).cloned().unwrap_or_default() as u64); + println!( + "Size: {} ({})", + size.to_string_as(true), + size.to_string_as(false) + ); + println!( + "Objects: {}", + counters.get(OBJECTS).cloned().unwrap_or_default() + ); + println!( + "Unfinished multipart uploads: {}", + counters + .get(UNFINISHED_UPLOADS) + .cloned() + .unwrap_or_default() + ); + println!("Website access: {}", p.website_config.get().is_some()); println!("\nGlobal aliases:"); |