Skip to content

Commit

Permalink
object: remove default value us-east-1 as region from s3 client
Browse files Browse the repository at this point in the history
Currently s3 client apis sets default value as `us-east-1`. This patch
removes that, region need to map with zonegroup in the RGW server so we
set that accordingly

Signed-off-by: Jiffin Tony Thottan <thottanjiffin@gmail.com>
  • Loading branch information
thotz committed Feb 17, 2022
1 parent a6fc3ae commit e8ba957
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion deploy/examples/storageclass-bucket-delete.yaml
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/examples/storageclass-bucket-retain.yaml
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion pkg/operator/ceph/object/bucket/provisioner.go
Expand Up @@ -513,7 +513,11 @@ func (p *Provisioner) setEndpoint(sc *storagev1.StorageClass) {

func (p *Provisioner) setRegion(sc *storagev1.StorageClass) {
const key = "region"
p.region = sc.Parameters[key]
if len(sc.Parameters[key]) > 0 {
p.region = sc.Parameters[key]
} else {
p.region = p.objectContext.ZoneGroup
}
}

func (p Provisioner) getObjectStoreEndpoint() string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/ceph/object/health.go
Expand Up @@ -165,7 +165,7 @@ func (c *bucketChecker) checkObjectStoreHealth() error {

// Initiate s3 agent
logger.Debugf("initializing s3 connection for object store %q", c.namespacedName.Name)
s3client, err := NewInsecureS3Agent(s3AccessKey, s3SecretKey, s3endpoint, "", false)
s3client, err := NewInsecureS3Agent(s3AccessKey, s3SecretKey, s3endpoint, c.objContext.ZoneGroup, false)
if err != nil {
return errors.Wrap(err, "failed to initialize s3 connection")
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/operator/ceph/object/s3-handlers.go
Expand Up @@ -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
Expand All @@ -64,7 +59,7 @@ func newS3Agent(accessKey, secretKey, endpoint, region string, debug bool, tlsCe
}
session, err := awssession.NewSession(
aws.NewConfig().
WithRegion(cephRegion).
WithRegion(region).
WithCredentials(credentials.NewStaticCredentials(accessKey, secretKey, "")).
WithEndpoint(endpoint).
WithS3ForcePathStyle(true).
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/clients/bucket.go
Expand Up @@ -157,9 +157,9 @@ func (b *BucketOperation) CheckBucketNotificationSetonRGW(namespace, storeName,
s3AccessKey, _ := helper.BucketClient.GetAccessKey(obcName)
s3SecretKey, _ := helper.BucketClient.GetSecretKey(obcName)
if tlsEnabled {
s3client, err = rgw.NewInsecureS3Agent(s3AccessKey, s3SecretKey, s3endpoint, "", true)
s3client, err = rgw.NewInsecureS3Agent(s3AccessKey, s3SecretKey, s3endpoint, storeName, true)
} else {
s3client, err = rgw.NewS3Agent(s3AccessKey, s3SecretKey, s3endpoint, "", true, nil)
s3client, err = rgw.NewS3Agent(s3AccessKey, s3SecretKey, s3endpoint, storeName, true, nil)
}
if err != nil {
logger.Infof("failed to s3client due to %v", err)
Expand Down

0 comments on commit e8ba957

Please sign in to comment.