Skip to content

Commit dfd64b1

Browse files
authored
Ceph object store: Fix LocationConstraint error (#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 02d1c61 commit dfd64b1

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
@@ -95,8 +95,8 @@ public Bucket createBucket(Bucket bucket, boolean objectLock) {
9595
AmazonS3 s3client = getS3Client(storeId, accountId);
9696

9797
try {
98-
if (s3client.getBucketAcl(bucketName) != null) {
99-
throw new CloudRuntimeException("Bucket already exists with name " + bucketName);
98+
if (s3client.doesBucketExistV2(bucketName)) {
99+
throw new CloudRuntimeException("Bucket already exists with the name: " + bucketName);
100100
}
101101
} catch (AmazonS3Exception e) {
102102
if (e.getStatusCode() != 404) {
@@ -221,9 +221,11 @@ public boolean createUser(long accountId, long storeId) {
221221
if (user.isPresent()) {
222222
logger.info("User already exists in Ceph RGW: " + username);
223223
return true;
224+
} else {
225+
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
224226
}
225227
} catch (Exception e) {
226-
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
228+
logger.debug("Get user info failed for user {} with exception {}. Proceeding with user creation.", username, e.getMessage());
227229
}
228230

229231
try {
@@ -348,7 +350,7 @@ protected AmazonS3 getS3Client(String url, String accessKey, String secretKey) {
348350
new AWSStaticCredentialsProvider(
349351
new BasicAWSCredentials(accessKey, secretKey)))
350352
.withEndpointConfiguration(
351-
new AwsClientBuilder.EndpointConfiguration(url, "auto"))
353+
new AwsClientBuilder.EndpointConfiguration(url, null))
352354
.build();
353355

354356
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)