diff options
author | Alex Auvolat <alex@adnab.me> | 2022-11-04 11:55:59 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-11-04 11:55:59 +0100 |
commit | 5b18fd8201af98798f0a47a95dfec2f3ab9777f8 (patch) | |
tree | 35693b8d63103e23673dccd91100d8fb6963c6b9 /src/garage/admin.rs | |
parent | 043246c575d1ae85c7f375ef577b8fef6940a6d5 (diff) | |
download | garage-5b18fd8201af98798f0a47a95dfec2f3ab9777f8.tar.gz garage-5b18fd8201af98798f0a47a95dfec2f3ab9777f8.zip |
Add garage bucket cleanup-incomplete-uploads commandcleanup-uploads-command
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..c21286e5 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("Bucket not found")?, + ); + } + + let duration = parse_duration::parse::parse(&query.older_than) + .ok_or_bad_request("Invalid duration")?; + + 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, |