From 91101b11bbf6d87ec5035b625f7c59cb6a30d0ae Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 12 Feb 2018 18:34:30 -0800 Subject: [PATCH] Converge repeated code to common deleteBucketMetadata() (#5508) --- cmd/fs-v1.go | 16 ++-------------- cmd/object-api-common.go | 19 +++++++++++++++++++ cmd/xl-v1-bucket.go | 17 ++--------------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 6ce74e7f5..679cf839b 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -346,22 +346,10 @@ func (fs *fsObjects) DeleteBucket(bucket string) error { if err = fsRemoveAll(minioMetadataBucketDir); err != nil { return toObjectErr(err, bucket) } - // Delete bucket access policy, if present - ignore any errors. - _ = removeBucketPolicy(bucket, fs) - // Notify all peers (including self) to update in-memory state - S3PeersUpdateBucketPolicy(bucket) + // Delete all bucket metadata. + deleteBucketMetadata(bucket, fs) - // Delete notification config, if present - ignore any errors. - _ = removeNotificationConfig(bucket, fs) - - // Notify all peers (including self) to update in-memory state - S3PeersUpdateBucketNotification(bucket, nil) - // Delete listener config, if present - ignore any errors. - _ = removeListenerConfig(bucket, fs) - - // Notify all peers (including self) to update in-memory state - S3PeersUpdateBucketListener(bucket, []listenerConfig{}) return nil } diff --git a/cmd/object-api-common.go b/cmd/object-api-common.go index 4d758a85a..24b51998d 100644 --- a/cmd/object-api-common.go +++ b/cmd/object-api-common.go @@ -85,6 +85,25 @@ func dirObjectInfo(bucket, object string, size int64, metadata map[string]string } } +func deleteBucketMetadata(bucket string, objAPI ObjectLayer) { + // Delete bucket access policy, if present - ignore any errors. + _ = removeBucketPolicy(bucket, objAPI) + + // Notify all peers (including self) to update in-memory state + S3PeersUpdateBucketPolicy(bucket) + + // Delete notification config, if present - ignore any errors. + _ = removeNotificationConfig(bucket, objAPI) + + // Notify all peers (including self) to update in-memory state + S3PeersUpdateBucketNotification(bucket, nil) + // Delete listener config, if present - ignore any errors. + _ = removeListenerConfig(bucket, objAPI) + + // Notify all peers (including self) to update in-memory state + S3PeersUpdateBucketListener(bucket, []listenerConfig{}) +} + // House keeping code for FS/XL and distributed Minio setup. func houseKeeping(storageDisks []StorageAPI) error { var wg = &sync.WaitGroup{} diff --git a/cmd/xl-v1-bucket.go b/cmd/xl-v1-bucket.go index 350f80eac..c0e408f9c 100644 --- a/cmd/xl-v1-bucket.go +++ b/cmd/xl-v1-bucket.go @@ -281,22 +281,9 @@ func (xl xlObjects) DeleteBucket(bucket string) error { if err != nil { return toObjectErr(err, bucket) } - // Delete bucket access policy, if present - ignore any errors. - _ = removeBucketPolicy(bucket, xl) - // Notify all peers (including self) to update in-memory state - S3PeersUpdateBucketPolicy(bucket) - - // Delete notification config, if present - ignore any errors. - _ = removeNotificationConfig(bucket, xl) - - // Notify all peers (including self) to update in-memory state - S3PeersUpdateBucketNotification(bucket, nil) - // Delete listener config, if present - ignore any errors. - _ = removeListenerConfig(bucket, xl) - - // Notify all peers (including self) to update in-memory state - S3PeersUpdateBucketListener(bucket, []listenerConfig{}) + // Delete all bucket metadata. + deleteBucketMetadata(bucket, xl) return nil }