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
This commit is contained in:
Abhisar Sinha 2025-05-01 11:47:18 +05:30 committed by GitHub
parent 02d1c61cf7
commit dfd64b1a67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -95,8 +95,8 @@ public class CephObjectStoreDriverImpl extends BaseObjectStoreDriverImpl {
AmazonS3 s3client = getS3Client(storeId, accountId); AmazonS3 s3client = getS3Client(storeId, accountId);
try { try {
if (s3client.getBucketAcl(bucketName) != null) { if (s3client.doesBucketExistV2(bucketName)) {
throw new CloudRuntimeException("Bucket already exists with name " + bucketName); throw new CloudRuntimeException("Bucket already exists with the name: " + bucketName);
} }
} catch (AmazonS3Exception e) { } catch (AmazonS3Exception e) {
if (e.getStatusCode() != 404) { if (e.getStatusCode() != 404) {
@ -221,9 +221,11 @@ public class CephObjectStoreDriverImpl extends BaseObjectStoreDriverImpl {
if (user.isPresent()) { if (user.isPresent()) {
logger.info("User already exists in Ceph RGW: " + username); logger.info("User already exists in Ceph RGW: " + username);
return true; return true;
} else {
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
} }
} catch (Exception e) { } catch (Exception e) {
logger.debug("User does not exist. Creating user in Ceph RGW: " + username); logger.debug("Get user info failed for user {} with exception {}. Proceeding with user creation.", username, e.getMessage());
} }
try { try {
@ -348,7 +350,7 @@ public class CephObjectStoreDriverImpl extends BaseObjectStoreDriverImpl {
new AWSStaticCredentialsProvider( new AWSStaticCredentialsProvider(
new BasicAWSCredentials(accessKey, secretKey))) new BasicAWSCredentials(accessKey, secretKey)))
.withEndpointConfiguration( .withEndpointConfiguration(
new AwsClientBuilder.EndpointConfiguration(url, "auto")) new AwsClientBuilder.EndpointConfiguration(url, null))
.build(); .build();
if (client == null) { if (client == null) {

View File

@ -96,7 +96,7 @@ public class CephObjectStoreDriverImplTest {
when(bucketDao.findById(anyLong())).thenReturn(new BucketVO(bucket.getName())); when(bucketDao.findById(anyLong())).thenReturn(new BucketVO(bucket.getName()));
Bucket bucketRet = cephObjectStoreDriverImpl.createBucket(bucket, false); Bucket bucketRet = cephObjectStoreDriverImpl.createBucket(bucket, false);
assertEquals(bucketRet.getName(), bucket.getName()); assertEquals(bucketRet.getName(), bucket.getName());
verify(rgwClient, times(1)).getBucketAcl(anyString()); verify(rgwClient, times(1)).doesBucketExistV2(anyString());
verify(rgwClient, times(1)).createBucket(anyString()); verify(rgwClient, times(1)).createBucket(anyString());
} }