mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-28 16:07:05 +00:00
fix:delete_bucket skip when volume not empty
This commit is contained in:
+2
-2
@@ -146,7 +146,7 @@ impl S3PeerSys {
|
|||||||
|
|
||||||
Ok(buckets)
|
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());
|
let mut futures = Vec::with_capacity(self.clients.len());
|
||||||
for cli in self.clients.iter() {
|
for cli in self.clients.iter() {
|
||||||
futures.push(cli.delete_bucket(bucket, &opts));
|
futures.push(cli.delete_bucket(bucket, &opts));
|
||||||
@@ -391,7 +391,7 @@ impl PeerS3Client for LocalPeerS3Client {
|
|||||||
let mut idx = 0;
|
let mut idx = 0;
|
||||||
for err in errs {
|
for err in errs {
|
||||||
if err.is_none() && recreate {
|
if err.is_none() && recreate {
|
||||||
let _ = self.local_disks[idx].make_volume(bucket).await;
|
let _ = local_disks[idx].make_volume(bucket).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx += 1;
|
idx += 1;
|
||||||
|
|||||||
@@ -488,6 +488,15 @@ impl StorageAPI for ECStore {
|
|||||||
|
|
||||||
Ok(buckets)
|
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<()> {
|
async fn make_bucket(&self, bucket: &str, opts: &MakeBucketOptions) -> Result<()> {
|
||||||
// TODO: check valid bucket name
|
// TODO: check valid bucket name
|
||||||
|
|
||||||
@@ -781,13 +790,4 @@ impl StorageAPI for ECStore {
|
|||||||
}
|
}
|
||||||
unimplemented!()
|
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
@@ -3,7 +3,7 @@ use ecstore::{
|
|||||||
erasure::{ReadAt, Write},
|
erasure::{ReadAt, Write},
|
||||||
peer::{LocalPeerS3Client, PeerS3Client},
|
peer::{LocalPeerS3Client, PeerS3Client},
|
||||||
store::{all_local_disk_path, find_local_disk},
|
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 tonic::{Request, Response, Status};
|
||||||
use tracing::{debug, error, info};
|
use tracing::{debug, error, info};
|
||||||
@@ -188,7 +188,11 @@ impl Node for NodeService {
|
|||||||
debug!("make bucket");
|
debug!("make bucket");
|
||||||
|
|
||||||
let request = request.into_inner();
|
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 {
|
Ok(_) => Ok(tonic::Response::new(DeleteBucketResponse {
|
||||||
success: true,
|
success: true,
|
||||||
error_info: None,
|
error_info: None,
|
||||||
|
|||||||
Reference in New Issue
Block a user