aws-sdk-java-v2 icon indicating copy to clipboard operation
aws-sdk-java-v2 copied to clipboard

TransferManager localhost endpoint not resolving correctly

Open kdelalic opened this issue 4 years ago • 8 comments

Describe the bug

I am overriding the TransferManager s3ConfigurationProperties endpoint with localhost because we are running s3Mock for testing. Making a request with TransferManager results in

java.util.concurrent.CompletionException: software.amazon.awssdk.core.exception.SdkClientException: Failed to send the request: Host name was invalid for dns resolution.

and based on the trace level logs, the bucket address is resolving as bucket-name.localhost

[DEBUG] [2022-11-10T01:06:41Z] [000000016df57000] [dns] - id=0x600000b70210: Host resolution requested for bucket-name.localhost
[DEBUG] [2022-11-10T01:06:41Z] [000000016df57000] [dns] - id=0x600000b70210: No cached entries found for bucket-name.localhost starting new resolver thread.

Expected Behavior

For the requests to succeed.

Current Behavior

Requests fail.

Reproduction Steps

Make a request using:

S3TransferManager transferManager = S3TransferManager.builder()
        .transferConfiguration(cfg -> cfg.executor(threadPoolExecutor))
        .s3ClientConfiguration(cfg -> cfg
            .endpointOverride("https://localhost:1234")
            .region(region)
            .build())
        .build();

with a mock service hosted on localhost:1234

Possible Solution

I wonder if this has anything to do with forcePathStyle not being exposed to TransferManager.

Additional Information/Context

TransferManager previously worked for this workflow in SDK V1.

AWS Java SDK version used

2.18.13-PREVIEW

JDK version used

openjdk-18.0.2.1

Operating System and version

Macbook Pro M1 Max MacOS Ventura 13.0

kdelalic avatar Nov 10 '22 01:11 kdelalic

Hello @kdelalic ,

Thank you very much for your submission. I apologize for any inconvenience. It seems like the behavior you are experiencing is a result of the following change introduced in v2.18.0:

When including an endpoint override, the SDK will use virtual bucket addressing as long as the bucket is a valid DNS label. This is different from the previous behavior where this only happens if the endpoint override begins with 's3'. see changelog

I will bring this up to the team. In the meantime a possible work around would be to use v2.17.295.

Sincerely,

Yasmine

yasminetalby avatar Nov 10 '22 22:11 yasminetalby

I am experiencing the exact same issue as @kdelalic. Is there anyway to set forcePathStyle to true?

peterson-dc avatar Nov 29 '22 16:11 peterson-dc

Hello @peterson-dc ,

Thank you very much for your comment. The issue is currently in the team's backlog. Once it is resolved the issue submission will be closed. If you are the S3TransferManager, the workaround would be to use v2.17.295. If you are using S3 you can set forcePathStyle to true as per this issue submission.

If you would like to showcase your interest, you can add a thumbs up to the main issue description. This helps us to see which submission are highly requested by the community.

Once this issue will be resolved the status of this submission will be updated to close to inform all participants.

Sincerely,

Yasmine

yasminetalby avatar Nov 29 '22 17:11 yasminetalby

I have updated my aws sdk to v2.19.15. With this version I am able to supply the S3TransferManager.Builder with an AsyncS3Client that I configured with forcePathStyle set to true. This has solved my issue with running integration tests that pointed to my localhost as the s3 endpoint override.

Thank you!

Here is an example of my configuration in kotlin.

val s3AsyncClient = S3AsyncClient.builder()
                    .forcePathStyle(true)
                    .endpointOverride(URI.create(endpoint))
                    .build()

val s3TransferManager = S3TransferManager.builder()
            .s3Client(s3AsyncClient)
            .build()

peterson-dc avatar Jan 18 '23 22:01 peterson-dc

@yasminetalby How can we configure the S3AsyncClient.crtBuilder() at the same way? There is no S3CrtAsyncClientBuilder#forcePathStyle method (we are missing lots of methods from S3BaseClientBuilder within S3CrtAsyncClientBuilder). Is there any workaround available?

almogtavor avatar Mar 07 '23 15:03 almogtavor

They got it fixed on 2.20.42. The property on the S3CrtAsyncClient named forcePathStyle(true) is now available for this given client.

alicianewhagen avatar Apr 10 '23 20:04 alicianewhagen

Closing this, S3CrtAsyncClient now supports forcePathStyle.

debora-ito avatar May 04 '23 00:05 debora-ito

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar May 04 '23 00:05 github-actions[bot]