Skip to content

Commit

Permalink
Merge pull request #78 from andyasp/clone-putUserMetadata
Browse files Browse the repository at this point in the history
S3: clone putUserMetadata map to prevent concurrent modification
  • Loading branch information
fpetkovski authored Sep 21, 2023
2 parents cac7ba2 + a557e75 commit 63a603e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#34](https://github.com/thanos-io/objstore/pull/34) Fix ignored options when creating shared credential Azure client.
- [#62](https://github.com/thanos-io/objstore/pull/62) S3: Fix ignored context cancellation in `Iter` method.
- [#77](https://github.com/thanos-io/objstore/pull/77) Fix buckets wrapped with metrics from being unable to determine object sizes in `Upload`.
- [#78](https://github.com/thanos-io/objstore/pull/78) S3: Fix possible concurrent modification of the PutUserMetadata map.

### Added
- [#15](https://github.com/thanos-io/objstore/pull/15) Add Oracle Cloud Infrastructure Object Storage Bucket support.
Expand Down
9 changes: 8 additions & 1 deletion providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,13 @@ func (b *Bucket) Upload(ctx context.Context, name string, r io.Reader) error {
if size < int64(partSize) {
partSize = 0
}

// Cloning map since minio may modify it
userMetadata := make(map[string]string, len(b.putUserMetadata))
for k, v := range b.putUserMetadata {
userMetadata[k] = v
}

if _, err := b.client.PutObject(
ctx,
b.name,
Expand All @@ -501,7 +508,7 @@ func (b *Bucket) Upload(ctx context.Context, name string, r io.Reader) error {
minio.PutObjectOptions{
PartSize: partSize,
ServerSideEncryption: sse,
UserMetadata: b.putUserMetadata,
UserMetadata: userMetadata,
StorageClass: b.storageClass,
// 4 is what minio-go have as the default. To be certain we do micro benchmark before any changes we
// ensure we pin this number to four.
Expand Down

0 comments on commit 63a603e

Please sign in to comment.