s3: Put bucket tagging to return an error when bucket is not found (#13232)

instead of creating new metadata in .minio.sys directory
This commit is contained in:
Anis Elleuch 2021-09-17 16:32:32 +01:00 committed by GitHub
parent d80826b05d
commit 91567ba916
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -1796,6 +1796,8 @@ func toAPIErrorCode(ctx context.Context, err error) (apiErr APIErrorCode) {
} }
switch err { switch err {
case errVolumeNotFound:
apiErr = ErrNoSuchBucket
case errInvalidArgument: case errInvalidArgument:
apiErr = ErrAdminInvalidArgument apiErr = ErrAdminInvalidArgument
case errNoSuchUser: case errNoSuchUser:

View File

@ -123,6 +123,9 @@ func (b *BucketMetadata) Load(ctx context.Context, api ObjectLayer, name string)
configFile := path.Join(bucketConfigPrefix, name, bucketMetadataFile) configFile := path.Join(bucketConfigPrefix, name, bucketMetadataFile)
data, err := readConfig(ctx, api, configFile) data, err := readConfig(ctx, api, configFile)
if err != nil { if err != nil {
if err == errConfigNotFound {
err = errVolumeNotFound
}
return err return err
} }
if len(data) <= 4 { 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) { func loadBucketMetadata(ctx context.Context, objectAPI ObjectLayer, bucket string) (BucketMetadata, error) {
b := newBucketMetadata(bucket) b := newBucketMetadata(bucket)
err := b.Load(ctx, objectAPI, b.Name) err := b.Load(ctx, objectAPI, b.Name)
if err != nil && !errors.Is(err, errConfigNotFound) { if err != nil {
return b, err return b, err
} }