Damans227 commented on code in PR #12426:
URL: https://github.com/apache/cloudstack/pull/12426#discussion_r2698595266
##########
utils/src/main/java/com/cloud/utils/storage/S3/S3Utils.java:
##########
@@ -114,6 +114,8 @@ public static TransferManager getTransferManager(final
ClientOptions clientOptio
LOGGER.debug(format("Setting the end point for S3 client with
access key %1$s to %2$s.", clientOptions.getAccessKey(),
clientOptions.getEndPoint()));
client.setEndpoint(clientOptions.getEndPoint());
+ // Enable path-style access for S3-compatible storage
+
client.setS3ClientOptions(com.amazonaws.services.s3.S3ClientOptions.builder().setPathStyleAccess(true).build());
Review Comment:
So, when debugging the issue... I noticed that the connection to MinIO
failed at the time of template upload, with an error that looked something
like:
`UnknownHostException: cloudstack-secondary.10.0.34.157` i.e. the SDK was
trying to connect to the `http://cloudstack-secondary.10.0.34.157:9000/...`
which is the virtual-hosted style (refer: [virtual style vs path style syntax
for
s3](https://kb.netapp.com/hybrid/StorageGRID/Grid_Tenant_Manager/What_is_path_style_vs_virtual_style)).
Looking at other S3-compatible plugins in CloudStack, I found that both
[CephObjectStoreDriverImpl](https://github.com/apache/cloudstack/blob/main/plugins/storage/object/ceph/src/main/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImpl.java#L348)
and
[CloudianHyperStoreUtil](https://github.com/apache/cloudstack/blob/main/plugins/storage/object/cloudian/src/main/java/org/apache/cloudstack/storage/datastore/util/CloudianHyperStoreUtil.java#L135)
use `enablePathStyleAccess()` to get path-style URLs
`http://10.0.34.157:9000/cloudstack-secondary/...` i.e.
```
AmazonS3 client = AmazonS3ClientBuilder.standard()
.enablePathStyleAccess()
.withCredentials(new AWSStaticCredentialsProvider(new
BasicAWSCredentials(accessKey, secretKey)))
.withEndpointConfiguration(new
AwsClientBuilder.EndpointConfiguration(url, "auto"))
.build();
```
Applying the same fix here worked. The [AWS SDK
documentation](https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/S3ClientOptions.Builder.html)
confirms that path-style access must be explicitly enabled for S3-compatible
stores.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]