From 467714f33bc7ffcbf455c3c3c52f6b89e7c0a15c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 28 Feb 2024 17:44:30 -0800 Subject: [PATCH] ignore x-amz-storage-class when its set to STANDARD (#19154) fixes #19135 --- cmd/endpoint.go | 1 + cmd/erasure-multipart.go | 6 ++++++ cmd/erasure-object.go | 6 ++++++ cmd/storage-rest-server.go | 2 +- cmd/xl-storage-format-v2.go | 7 +++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cmd/endpoint.go b/cmd/endpoint.go index c0fe711a0..7c69ba37d 100644 --- a/cmd/endpoint.go +++ b/cmd/endpoint.go @@ -75,6 +75,7 @@ type Endpoint struct { PoolIdx, SetIdx, DiskIdx int } +// Equal returns true if endpoint == ep func (endpoint Endpoint) Equal(ep Endpoint) bool { if endpoint.IsLocal == ep.IsLocal && endpoint.PoolIdx == ep.PoolIdx && endpoint.SetIdx == ep.SetIdx && endpoint.DiskIdx == ep.DiskIdx { if endpoint.Path == ep.Path && endpoint.Host == ep.Host { diff --git a/cmd/erasure-multipart.go b/cmd/erasure-multipart.go index 165b8a61b..6e7412db9 100644 --- a/cmd/erasure-multipart.go +++ b/cmd/erasure-multipart.go @@ -33,6 +33,7 @@ import ( "github.com/klauspost/readahead" "github.com/minio/minio-go/v7/pkg/set" + "github.com/minio/minio/internal/config/storageclass" "github.com/minio/minio/internal/crypto" "github.com/minio/minio/internal/hash" xhttp "github.com/minio/minio/internal/http" @@ -461,6 +462,11 @@ func (er erasureObjects) newMultipartUpload(ctx context.Context, bucket string, userDefined["content-type"] = mimedb.TypeByExtension(path.Ext(object)) } + // if storageClass is standard no need to save it as part of metadata. + if userDefined[xhttp.AmzStorageClass] == storageclass.STANDARD { + delete(userDefined, xhttp.AmzStorageClass) + } + if opts.WantChecksum != nil && opts.WantChecksum.Type.IsSet() { userDefined[hash.MinIOMultipartChecksum] = opts.WantChecksum.Type.String() } diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 91413a369..49bdd035b 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -37,6 +37,7 @@ import ( "github.com/minio/minio/internal/bucket/lifecycle" "github.com/minio/minio/internal/bucket/object/lock" "github.com/minio/minio/internal/bucket/replication" + "github.com/minio/minio/internal/config/storageclass" "github.com/minio/minio/internal/crypto" "github.com/minio/minio/internal/event" "github.com/minio/minio/internal/hash" @@ -1509,6 +1510,11 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st userDefined["content-type"] = mimedb.TypeByExtension(path.Ext(object)) } + // if storageClass is standard no need to save it as part of metadata. + if userDefined[xhttp.AmzStorageClass] == storageclass.STANDARD { + delete(userDefined, xhttp.AmzStorageClass) + } + // Fill all the necessary metadata. // Update `xl.meta` content on each disks. for index := range partsMetadata { diff --git a/cmd/storage-rest-server.go b/cmd/storage-rest-server.go index 4d064eb1b..9f5412cae 100644 --- a/cmd/storage-rest-server.go +++ b/cmd/storage-rest-server.go @@ -81,7 +81,7 @@ func getStorageViaEndpoint(endpoint Endpoint) StorageAPI { if len(globalLocalSetDrives) == 0 { for _, drive := range globalLocalDrives { if drive != nil && drive.Endpoint().Equal(endpoint) { - return drive + return drive } } } diff --git a/cmd/xl-storage-format-v2.go b/cmd/xl-storage-format-v2.go index 4b234b314..a51441b79 100644 --- a/cmd/xl-storage-format-v2.go +++ b/cmd/xl-storage-format-v2.go @@ -35,6 +35,7 @@ import ( jsoniter "github.com/json-iterator/go" "github.com/minio/minio/internal/bucket/lifecycle" "github.com/minio/minio/internal/bucket/replication" + "github.com/minio/minio/internal/config/storageclass" xhttp "github.com/minio/minio/internal/http" "github.com/minio/minio/internal/logger" "github.com/minio/pkg/v2/env" @@ -639,6 +640,9 @@ func (j xlMetaV2Object) ToFileInfo(volume, path string, allParts bool) (FileInfo if equals(k, xhttp.AmzMetaUnencryptedContentLength, xhttp.AmzMetaUnencryptedContentMD5) { continue } + if equals(k, "x-amz-storage-class") && v == storageclass.STANDARD { + continue + } fi.Metadata[k] = v } @@ -655,6 +659,9 @@ func (j xlMetaV2Object) ToFileInfo(volume, path string, allParts bool) (FileInfo continue } } + if equals(k, "x-amz-storage-class") && string(v) == storageclass.STANDARD { + continue + } switch { case strings.HasPrefix(strings.ToLower(k), ReservedMetadataPrefixLower), equals(k, VersionPurgeStatusKey): fi.Metadata[k] = string(v)