Skip to content

Commit 924cdd8

Browse files
imsayari404Presto CUDF CI
authored andcommitted
migrate to AWS SDK v2 with MinIO compatibility fixes
Disable checksum validation and chunked encoding to ensure compatibility with MinIO and newer AWS SDK versions per aws/aws-sdk-java-v2#5836
1 parent 8cde267 commit 924cdd8

File tree

3 files changed

+83
-27
lines changed

3 files changed

+83
-27
lines changed

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
<air.test.jvmsize>4g</air.test.jvmsize>
105105
<grpc.version>1.70.0</grpc.version>
106106
<air.javadoc.lint>-missing</air.javadoc.lint>
107+
<dep.commons.codec.version>1.17.1</dep.commons.codec.version>
108+
<aws.sdk.version>2.32.9</aws.sdk.version>
107109
</properties>
108110

109111
<modules>
@@ -221,6 +223,14 @@
221223
<dependencyManagement>
222224
<dependencies>
223225

226+
<dependency>
227+
<groupId>software.amazon.awssdk</groupId>
228+
<artifactId>bom</artifactId>
229+
<version>${aws.sdk.version}</version>
230+
<type>pom</type>
231+
<scope>import</scope>
232+
</dependency>
233+
224234
<dependency>
225235
<groupId>commons-beanutils</groupId>
226236
<artifactId>commons-beanutils</artifactId>
@@ -2005,7 +2015,7 @@
20052015
<dependency>
20062016
<groupId>commons-codec</groupId>
20072017
<artifactId>commons-codec</artifactId>
2008-
<version>1.17.0</version>
2018+
<version>${dep.commons.codec.version}</version>
20092019
</dependency>
20102020

20112021
<dependency>
@@ -2759,6 +2769,7 @@
27592769
</ignoredClassPatterns>
27602770
<ignoredResourcePatterns combine.children="append">
27612771
<ignoredResourcePattern>git.properties</ignoredResourcePattern>
2772+
<ignoredResourcePattern>mime.types</ignoredResourcePattern>
27622773
</ignoredResourcePatterns>
27632774
</configuration>
27642775
</plugin>

presto-iceberg/pom.xml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</dependencyManagement>
3131

3232
<dependencies>
33+
3334
<dependency>
3435
<groupId>com.facebook.airlift</groupId>
3536
<artifactId>concurrent</artifactId>
@@ -286,16 +287,6 @@
286287
</exclusions>
287288
</dependency>
288289

289-
<dependency>
290-
<groupId>com.amazonaws</groupId>
291-
<artifactId>aws-java-sdk-core</artifactId>
292-
</dependency>
293-
294-
<dependency>
295-
<groupId>com.amazonaws</groupId>
296-
<artifactId>aws-java-sdk-s3</artifactId>
297-
</dependency>
298-
299290
<dependency>
300291
<groupId>org.apache.iceberg</groupId>
301292
<artifactId>iceberg-core</artifactId>
@@ -531,6 +522,37 @@
531522
</dependency>
532523

533524
<!-- for testing -->
525+
526+
<dependency>
527+
<groupId>software.amazon.awssdk</groupId>
528+
<artifactId>s3</artifactId>
529+
<scope>test</scope>
530+
</dependency>
531+
532+
<dependency>
533+
<groupId>software.amazon.awssdk</groupId>
534+
<artifactId>regions</artifactId>
535+
<scope>test</scope>
536+
</dependency>
537+
538+
<dependency>
539+
<groupId>software.amazon.awssdk</groupId>
540+
<artifactId>sdk-core</artifactId>
541+
<scope>test</scope>
542+
</dependency>
543+
544+
<dependency>
545+
<groupId>software.amazon.awssdk</groupId>
546+
<artifactId>auth</artifactId>
547+
<scope>test</scope>
548+
</dependency>
549+
550+
<dependency>
551+
<groupId>software.amazon.awssdk</groupId>
552+
<artifactId>aws-core</artifactId>
553+
<scope>test</scope>
554+
</dependency>
555+
534556
<dependency>
535557
<groupId>org.openjdk.jmh</groupId>
536558
<artifactId>jmh-core</artifactId>

presto-iceberg/src/test/java/com/facebook/presto/iceberg/container/IcebergMinIODataLake.java

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,22 @@
1313
*/
1414
package com.facebook.presto.iceberg.container;
1515

16-
import com.amazonaws.auth.AWSStaticCredentialsProvider;
17-
import com.amazonaws.auth.BasicAWSCredentials;
18-
import com.amazonaws.client.builder.AwsClientBuilder;
19-
import com.amazonaws.services.s3.AmazonS3;
20-
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
2116
import com.facebook.presto.testing.containers.MinIOContainer;
2217
import com.facebook.presto.util.AutoCloseableCloser;
2318
import com.google.common.collect.ImmutableMap;
2419
import org.testcontainers.containers.Network;
20+
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
21+
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
22+
import software.amazon.awssdk.core.sync.RequestBody;
23+
import software.amazon.awssdk.regions.Region;
24+
import software.amazon.awssdk.services.s3.S3Client;
25+
import software.amazon.awssdk.services.s3.S3Configuration;
26+
import software.amazon.awssdk.services.s3.model.CreateBucketRequest;
27+
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
2528

2629
import java.io.Closeable;
2730
import java.io.IOException;
31+
import java.net.URI;
2832
import java.util.concurrent.atomic.AtomicBoolean;
2933

3034
import static java.util.Objects.requireNonNull;
@@ -39,7 +43,6 @@ public class IcebergMinIODataLake
3943
private final String bucketName;
4044
private final String warehouseDir;
4145
private final MinIOContainer minIOContainer;
42-
4346
private final AtomicBoolean isStarted = new AtomicBoolean(false);
4447
private final AutoCloseableCloser closer = AutoCloseableCloser.create();
4548

@@ -63,19 +66,39 @@ public void start()
6366
if (isStarted()) {
6467
return;
6568
}
69+
6670
try {
6771
this.minIOContainer.start();
68-
AmazonS3 s3Client = AmazonS3ClientBuilder
69-
.standard()
70-
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
71-
"http://localhost:" + minIOContainer.getMinioApiEndpoint().getPort(),
72-
"us-east-1"))
73-
.withPathStyleAccessEnabled(true)
74-
.withCredentials(new AWSStaticCredentialsProvider(
75-
new BasicAWSCredentials(ACCESS_KEY, SECRET_KEY)))
72+
73+
S3Client s3Client = S3Client.builder()
74+
.endpointOverride(URI.create("http://localhost:" + minIOContainer.getMinioApiEndpoint().getPort()))
75+
.region(Region.US_EAST_1)
76+
.forcePathStyle(true)
77+
.serviceConfiguration(S3Configuration.builder()
78+
// Disable checksum validation and chunked encoding for MinIO compatibility
79+
// MinIO checksum handling differs from AWS S3
80+
// Prevents chunked transfer encoding issues with MinIO
81+
.checksumValidationEnabled(false)
82+
.chunkedEncodingEnabled(false)
83+
.build())
84+
.credentialsProvider(StaticCredentialsProvider.create(
85+
AwsBasicCredentials.create(ACCESS_KEY, SECRET_KEY)))
7686
.build();
77-
s3Client.createBucket(this.bucketName);
78-
s3Client.putObject(this.bucketName, this.warehouseDir, "");
87+
88+
s3Client.createBucket(CreateBucketRequest.builder()
89+
.bucket(this.bucketName)
90+
.build());
91+
String objectKey = this.warehouseDir.endsWith("/")
92+
? this.warehouseDir + ".keep"
93+
: this.warehouseDir + "/.keep";
94+
95+
s3Client.putObject(
96+
PutObjectRequest.builder()
97+
.bucket(this.bucketName)
98+
.key(objectKey)
99+
.build(),
100+
RequestBody.fromString("placeholder"));
101+
closer.register(s3Client);
79102
}
80103
finally {
81104
isStarted.set(true);

0 commit comments

Comments
 (0)