fix:delete_bucket skip when volume not empty

This commit is contained in:
weisd
2024-09-13 14:15:09 +08:00
parent 2dd46203ee
commit 210d7a4d59
3 changed files with 17 additions and 13 deletions
+2 -2
View File
@@ -146,7 +146,7 @@ impl S3PeerSys {
Ok(buckets)
}
async fn delete_bucket(&self, bucket: &str, opts: &DeleteBucketOptions) -> Result<()> {
pub async fn delete_bucket(&self, bucket: &str, opts: &DeleteBucketOptions) -> Result<()> {
let mut futures = Vec::with_capacity(self.clients.len());
for cli in self.clients.iter() {
futures.push(cli.delete_bucket(bucket, &opts));
@@ -391,7 +391,7 @@ impl PeerS3Client for LocalPeerS3Client {
let mut idx = 0;
for err in errs {
if err.is_none() && recreate {
let _ = self.local_disks[idx].make_volume(bucket).await;
let _ = local_disks[idx].make_volume(bucket).await;
}
idx += 1;
+9 -9
View File
@@ -488,6 +488,15 @@ impl StorageAPI for ECStore {
Ok(buckets)
}
async fn delete_bucket(&self, bucket: &str, opts: &DeleteBucketOptions) -> Result<()> {
self.peer_sys.delete_bucket(bucket, opts).await?;
// 删除meta
self.delete_all(RUSTFS_META_BUCKET, format!("{}/{}", BUCKET_META_PREFIX, bucket).as_str())
.await?;
Ok(())
}
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()> {
// TODO: check valid bucket name
@@ -781,13 +790,4 @@ impl StorageAPI for ECStore {
}
unimplemented!()
}
async fn delete_bucket(&self, bucket: &str, opts: &DeleteBucketOptions) -> Result<()> {
self.peer_sys.delete_bucket(bucket, opts).await?;
// 删除meta
self.delete_all(RUSTFS_META_BUCKET, format!("{}/{}", BUCKET_META_PREFIX, bucket).as_str())
.await?;
Ok(())
}
}
+6 -2
View File
@@ -3,7 +3,7 @@ use ecstore::{
erasure::{ReadAt, Write},
peer::{LocalPeerS3Client, PeerS3Client},
store::{all_local_disk_path, find_local_disk},
store_api::{BucketOptions, FileInfo, MakeBucketOptions},
store_api::{BucketOptions, DeleteBucketOptions, FileInfo, MakeBucketOptions},
};
use tonic::{Request, Response, Status};
use tracing::{debug, error, info};
@@ -188,7 +188,11 @@ impl Node for NodeService {
debug!("make bucket");
let request = request.into_inner();
match self.local_peer.delete_bucket(&request.bucket).await {
match self
.local_peer
.delete_bucket(&request.bucket, &DeleteBucketOptions { force: false })
.await
{
Ok(_) => Ok(tonic::Response::new(DeleteBucketResponse {
success: true,
error_info: None,