From d1737199ed14a02cae3effe484e1cea70445b587 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 21 Apr 2023 12:12:31 -0700 Subject: [PATCH] fix: delete DNS upon success, update failure message (#17059) --- cmd/bucket-handlers.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/cmd/bucket-handlers.go b/cmd/bucket-handlers.go index 40f417aa1..d96593ae5 100644 --- a/cmd/bucket-handlers.go +++ b/cmd/bucket-handlers.go @@ -1324,14 +1324,6 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http. } } - if globalDNSConfig != nil { - if err := globalDNSConfig.Delete(bucket); err != nil { - logger.LogIf(ctx, fmt.Errorf("Unable to delete bucket DNS entry %w, please delete it manually", err)) - writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) - return - } - } - deleteBucket := objectAPI.DeleteBucket // Attempt to delete bucket. @@ -1345,15 +1337,18 @@ func (api objectAPIHandlers) DeleteBucketHandler(w http.ResponseWriter, r *http. apiErr.Description = "The bucket you tried to delete is not empty. You must delete all versions in the bucket." } } - if globalDNSConfig != nil { - if err2 := globalDNSConfig.Put(bucket); err2 != nil { - logger.LogIf(ctx, fmt.Errorf("Unable to restore bucket DNS entry %w, please fix it manually", err2)) - } - } writeErrorResponse(ctx, w, apiErr, r.URL) return } + if globalDNSConfig != nil { + if err := globalDNSConfig.Delete(bucket); err != nil { + logger.LogIf(ctx, fmt.Errorf("Unable to delete bucket DNS entry %w, please delete it manually, bucket on MinIO no longer exists", err)) + writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL) + return + } + } + globalNotificationSys.DeleteBucketMetadata(ctx, bucket) globalReplicationPool.deleteResyncMetadata(ctx, bucket)