From 572bbaed0ef8f1912b540d050477099c00779b2e Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Wed, 16 Feb 2022 15:54:41 +0530 Subject: [PATCH] object: remove default value us-east-1 as region from s3 client Currently s3 client apis sets default value as `us-east-1`. This patch removes that, since if the region is not mention RGW server will pick default zonegroup while handling the request. Signed-off-by: Jiffin Tony Thottan --- .../examples/storageclass-bucket-delete.yaml | 2 +- .../examples/storageclass-bucket-retain.yaml | 2 +- pkg/operator/ceph/object/s3-handlers.go | 28 ++++++++----------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/deploy/examples/storageclass-bucket-delete.yaml b/deploy/examples/storageclass-bucket-delete.yaml index 63b25fabdadbe..f9507b754ba74 100644 --- a/deploy/examples/storageclass-bucket-delete.yaml +++ b/deploy/examples/storageclass-bucket-delete.yaml @@ -9,7 +9,7 @@ reclaimPolicy: Delete parameters: objectStoreName: my-store objectStoreNamespace: rook-ceph # namespace:cluster - region: us-east-1 + # region: us-east-1 # To accommodate brownfield cases reference the existing bucket name here instead # of in the ObjectBucketClaim (OBC). In this case the provisioner will grant # access to the bucket by creating a new user, attaching it to the bucket, and diff --git a/deploy/examples/storageclass-bucket-retain.yaml b/deploy/examples/storageclass-bucket-retain.yaml index 37361a8467b48..03a5094f5c050 100644 --- a/deploy/examples/storageclass-bucket-retain.yaml +++ b/deploy/examples/storageclass-bucket-retain.yaml @@ -8,7 +8,7 @@ reclaimPolicy: Retain parameters: objectStoreName: my-store # port 80 assumed objectStoreNamespace: rook-ceph # namespace:cluster - region: us-east-1 + # region: us-east-1 # To accommodate brownfield cases reference the existing bucket name here instead # of in the ObjectBucketClaim (OBC). In this case the provisioner will grant # access to the bucket by creating a new user, attaching it to the bucket, and diff --git a/pkg/operator/ceph/object/s3-handlers.go b/pkg/operator/ceph/object/s3-handlers.go index 479aaf09bddb5..4af16a0a4f763 100644 --- a/pkg/operator/ceph/object/s3-handlers.go +++ b/pkg/operator/ceph/object/s3-handlers.go @@ -45,11 +45,6 @@ func NewInsecureS3Agent(accessKey, secretKey, endpoint, region string, debug boo } func newS3Agent(accessKey, secretKey, endpoint, region string, debug bool, tlsCert []byte, insecure bool) (*S3Agent, error) { - var cephRegion = "us-east-1" - if region != "" { - cephRegion = region - } - logLevel := aws.LogOff if debug { logLevel = aws.LogDebug @@ -62,17 +57,18 @@ func newS3Agent(accessKey, secretKey, endpoint, region string, debug bool, tlsCe tlsEnabled = true client.Transport = BuildTransportTLS(tlsCert, insecure) } - session, err := awssession.NewSession( - aws.NewConfig(). - WithRegion(cephRegion). - WithCredentials(credentials.NewStaticCredentials(accessKey, secretKey, "")). - WithEndpoint(endpoint). - WithS3ForcePathStyle(true). - WithMaxRetries(5). - WithDisableSSL(!tlsEnabled). - WithHTTPClient(&client). - WithLogLevel(logLevel), - ) + awsConfig := aws.NewConfig(). + WithCredentials(credentials.NewStaticCredentials(accessKey, secretKey, "")). + WithEndpoint(endpoint). + WithS3ForcePathStyle(true). + WithMaxRetries(5). + WithDisableSSL(!tlsEnabled). + WithHTTPClient(&client). + WithLogLevel(logLevel) + if region != "" { + awsConfig = awsConfig.WithRegion(region) + } + session, err := awssession.NewSession(awsConfig) if err != nil { return nil, err }