diff options
author | Alex Auvolat <alex@adnab.me> | 2022-11-07 12:20:59 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-11-07 12:20:59 +0100 |
commit | 28d7a49f6365fadaffaa903cc10434c1ed28d564 (patch) | |
tree | 8da5b3213b7ff199af80e64af29a7a1395b9d02d /src/garage/admin.rs | |
parent | 3039bb5d431532f0ec907eab5e00f94acc4a3472 (diff) | |
parent | 66f2daa0259538c64508b37cec89d76a74a71a02 (diff) | |
download | garage-28d7a49f6365fadaffaa903cc10434c1ed28d564.tar.gz garage-28d7a49f6365fadaffaa903cc10434c1ed28d564.zip |
Merge branch 'main' into optimal-layout
Diffstat (limited to 'src/garage/admin.rs')
-rw-r--r-- | src/garage/admin.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/garage/admin.rs b/src/garage/admin.rs index 802a8261..e973cfe7 100644 --- a/src/garage/admin.rs +++ b/src/garage/admin.rs @@ -85,6 +85,9 @@ impl AdminRpcHandler { BucketOperation::Deny(query) => self.handle_bucket_deny(query).await, BucketOperation::Website(query) => self.handle_bucket_website(query).await, BucketOperation::SetQuotas(query) => self.handle_bucket_set_quotas(query).await, + BucketOperation::CleanupIncompleteUploads(query) => { + self.handle_bucket_cleanup_incomplete_uploads(query).await + } } } @@ -512,6 +515,42 @@ impl AdminRpcHandler { ))) } + async fn handle_bucket_cleanup_incomplete_uploads( + &self, + query: &CleanupIncompleteUploadsOpt, + ) -> Result<AdminRpc, Error> { + let mut bucket_ids = vec![]; + for b in query.buckets.iter() { + bucket_ids.push( + self.garage + .bucket_helper() + .resolve_global_bucket_name(b) + .await? + .ok_or_bad_request(format!("Bucket not found: {}", b))?, + ); + } + + let duration = parse_duration::parse::parse(&query.older_than) + .ok_or_bad_request("Invalid duration passed for --older-than parameter")?; + + let mut ret = String::new(); + for bucket in bucket_ids { + let count = self + .garage + .bucket_helper() + .cleanup_incomplete_uploads(&bucket, duration) + .await?; + writeln!( + &mut ret, + "Bucket {:?}: {} incomplete uploads aborted", + bucket, count + ) + .unwrap(); + } + + Ok(AdminRpc::Ok(ret)) + } + async fn handle_key_cmd(&self, cmd: &KeyOperation) -> Result<AdminRpc, Error> { match cmd { KeyOperation::List => self.handle_list_keys().await, |