Skip to content

Commit 38582ac

Browse files
fix: Do not override S3 region if already specified in configuration chain (backport release-3.6.x) (#20128)
Signed-off-by: Christian Haudum <christian.haudum@gmail.com> Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
1 parent 7d8176f commit 38582ac

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

pkg/storage/chunk/client/aws/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestS3ClientOptions(t *testing.T) {
108108
opts := s3.Options{}
109109
fn(&opts)
110110

111-
require.Equal(t, "", opts.Region)
111+
require.Equal(t, InvalidAWSRegion, opts.Region) // it is still required to set region explicitly
112112
require.Equal(t, "http://s3.us-east-0.amazonaws.com", *opts.BaseEndpoint)
113113
})
114114

@@ -120,7 +120,7 @@ func TestS3ClientOptions(t *testing.T) {
120120
opts := s3.Options{}
121121
fn(&opts)
122122

123-
require.Equal(t, "", opts.Region)
123+
require.Equal(t, InvalidAWSRegion, opts.Region) // it is still required to set region explicitly
124124
require.Equal(t, "https://s3.us-east-0.amazonaws.com", *opts.BaseEndpoint)
125125
})
126126

pkg/storage/chunk/client/aws/s3_storage_client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ func s3ClientConfigFunc(cfg S3Config, hedgingCfg hedging.Config, hedging bool) (
316316
// s3://<key>:<secret>@us-east-0/<bucketname>
317317
opts.Region = awsURL.Host
318318
}
319-
} else {
319+
}
320+
if opts.Region == "" {
321+
// Not sure why this is needed, but test otherwise time out when run in CI
320322
opts.Region = InvalidAWSRegion
321323
}
322324

0 commit comments

Comments
 (0)