Skip to content

Commit 789ab7b

Browse files
abh1sardhslove
authored andcommitted
Ceph object store: Fix LocationConstraint error (apache#10772)
* Don't set signingRegion as auto for creating the s3 client in ceph object store provider. * replace getBucketAcl with doesBucketExistV2 in CephObjectStoreDriverImplTest
1 parent a7eda46 commit 789ab7b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

plugins/storage/object/ceph/src/main/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public Bucket createBucket(Bucket bucket, boolean objectLock) {
105105
AmazonS3 s3client = getS3Client(storeId, accountId);
106106

107107
try {
108-
if (s3client.getBucketAcl(bucketName) != null) {
109-
throw new CloudRuntimeException("Bucket already exists with name " + bucketName);
108+
if (s3client.doesBucketExistV2(bucketName)) {
109+
throw new CloudRuntimeException("Bucket already exists with the name: " + bucketName);
110110
}
111111
} catch (AmazonS3Exception e) {
112112
if (e.getStatusCode() != 404) {
@@ -274,9 +274,11 @@ public boolean createUser(long accountId, long storeId) {
274274
if (user.isPresent()) {
275275
logger.info("User already exists in Ceph RGW: " + username);
276276
return true;
277+
} else {
278+
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
277279
}
278280
} catch (Exception e) {
279-
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
281+
logger.debug("Get user info failed for user {} with exception {}. Proceeding with user creation.", username, e.getMessage());
280282
}
281283

282284
try {
@@ -402,7 +404,7 @@ protected AmazonS3 getS3Client(String url, String accessKey, String secretKey) {
402404
new AWSStaticCredentialsProvider(
403405
new BasicAWSCredentials(accessKey, secretKey)))
404406
.withEndpointConfiguration(
405-
new AwsClientBuilder.EndpointConfiguration(url, "auto"))
407+
new AwsClientBuilder.EndpointConfiguration(url, null))
406408
.build();
407409

408410
if (client == null) {

plugins/storage/object/ceph/src/test/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testCreateBucket() throws Exception {
9696
when(bucketDao.findById(anyLong())).thenReturn(new BucketVO(bucket.getName()));
9797
Bucket bucketRet = cephObjectStoreDriverImpl.createBucket(bucket, false);
9898
assertEquals(bucketRet.getName(), bucket.getName());
99-
verify(rgwClient, times(1)).getBucketAcl(anyString());
99+
verify(rgwClient, times(1)).doesBucketExistV2(anyString());
100100
verify(rgwClient, times(1)).createBucket(anyString());
101101
}
102102

0 commit comments

Comments
 (0)