From 91567ba91615b4f12a12de31d64c03a3bc20f706 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 17 Sep 2021 16:32:32 +0100 Subject: [PATCH] s3: Put bucket tagging to return an error when bucket is not found (#13232) instead of creating new metadata in .minio.sys directory --- cmd/api-errors.go | 2 ++ cmd/bucket-metadata.go | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/api-errors.go b/cmd/api-errors.go index c0879ef7c..068dee03e 100644 --- a/cmd/api-errors.go +++ b/cmd/api-errors.go @@ -1796,6 +1796,8 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) { } switch err { + case errVolumeNotFound: + apiErr = ErrNoSuchBucket case errInvalidArgument: apiErr = ErrAdminInvalidArgument case errNoSuchUser: diff --git a/cmd/bucket-metadata.go b/cmd/bucket-metadata.go index f2142a0f3..41bb32436 100644 --- a/cmd/bucket-metadata.go +++ b/cmd/bucket-metadata.go @@ -123,6 +123,9 @@ func (b *BucketMetadata) Load(ctx context.Context, api ObjectLayer, name string) configFile := path.Join(bucketConfigPrefix, name, bucketMetadataFile) data, err := readConfig(ctx, api, configFile) if err != nil { + if err == errConfigNotFound { + err = errVolumeNotFound + } return err } if len(data) <= 4 { @@ -149,7 +152,7 @@ func (b *BucketMetadata) Load(ctx context.Context, api ObjectLayer, name string) func loadBucketMetadata(ctx context.Context, objectAPI ObjectLayer, bucket string) (BucketMetadata, error) { b := newBucketMetadata(bucket) err := b.Load(ctx, objectAPI, b.Name) - if err != nil && !errors.Is(err, errConfigNotFound) { + if err != nil { return b, err }