Skip to content

Commit 83185e7

Browse files
committed
S3: Disable strong integrity checksums
1 parent e509cfc commit 83185e7

File tree

7 files changed

+60
-7
lines changed

7 files changed

+60
-7
lines changed

aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ private List<String> deleteBatch(String bucket, Collection<String> keysToDelete)
275275
DeleteObjectsRequest.builder()
276276
.bucket(bucket)
277277
.delete(Delete.builder().objects(objectIds).build())
278+
.overrideConfiguration(S3RequestUtil.disableStrongIntegrityChecksums())
278279
.build();
279280
List<String> failures = Lists.newArrayList();
280281
try {

aws/src/main/java/org/apache/iceberg/aws/s3/S3OutputStream.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,10 @@ private void completeUploads() {
424424
.orElseGet(() -> new ByteArrayInputStream(new byte[0])));
425425

426426
PutObjectRequest.Builder requestBuilder =
427-
PutObjectRequest.builder().bucket(location.bucket()).key(location.key());
427+
PutObjectRequest.builder()
428+
.bucket(location.bucket())
429+
.key(location.key())
430+
.overrideConfiguration(S3RequestUtil.disableStrongIntegrityChecksums());
428431

429432
if (writeTags != null && !writeTags.isEmpty()) {
430433
requestBuilder.tagging(Tagging.builder().tagSet(writeTags).build());

aws/src/main/java/org/apache/iceberg/aws/s3/S3RequestUtil.java

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import java.util.Locale;
2222
import java.util.function.Function;
23+
import software.amazon.awssdk.auth.signer.AwsS3V4Signer;
24+
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
2325
import software.amazon.awssdk.services.s3.model.CreateMultipartUploadRequest;
2426
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
2527
import software.amazon.awssdk.services.s3.model.HeadObjectRequest;
@@ -149,4 +151,10 @@ static void configurePermission(
149151
Function<ObjectCannedACL, S3Request.Builder> aclSetter) {
150152
aclSetter.apply(s3FileIOProperties.acl());
151153
}
154+
155+
// TODO Remove me once all of the S3-compatible storage support strong integrity checks
156+
@SuppressWarnings("deprecation")
157+
static AwsRequestOverrideConfiguration disableStrongIntegrityChecksums() {
158+
return AwsRequestOverrideConfiguration.builder().signer(AwsS3V4Signer.create()).build();
159+
}
152160
}

aws/src/test/java/org/apache/iceberg/aws/s3/MinioUtil.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@
2929
import software.amazon.awssdk.services.s3.S3ClientBuilder;
3030

3131
public class MinioUtil {
32+
public static final String LATEST_TAG = "latest";
33+
// This version doesn't support strong integrity checks
34+
static final String LEGACY_TAG = "RELEASE.2024-12-18T13-15-44Z";
3235

3336
private MinioUtil() {}
3437

3538
public static MinIOContainer createContainer() {
36-
return createContainer(null);
39+
return createContainer(LATEST_TAG, null);
3740
}
3841

39-
public static MinIOContainer createContainer(AwsCredentials credentials) {
40-
var container = new MinIOContainer(DockerImageName.parse("minio/minio:latest"));
42+
public static MinIOContainer createContainer(String tag, AwsCredentials credentials) {
43+
var container = new MinIOContainer(DockerImageName.parse("minio/minio").withTag(tag));
4144

4245
// this enables virtual-host-style requests. see
4346
// https://github.com/minio/minio/tree/master/docs/config#domain

aws/src/test/java/org/apache/iceberg/aws/s3/TestS3FileIO.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@
105105

106106
@Testcontainers
107107
public class TestS3FileIO {
108-
@Container private static final MinIOContainer MINIO = MinioUtil.createContainer();
108+
@Container private final MinIOContainer minio = createMinIOContainer();
109109

110-
private final SerializableSupplier<S3Client> s3 = () -> MinioUtil.createS3Client(MINIO);
110+
private final SerializableSupplier<S3Client> s3 = () -> MinioUtil.createS3Client(minio);
111111
private final S3Client s3mock = mock(S3Client.class, delegatesTo(s3.get()));
112112
private final Random random = new Random(1);
113113
private final int numBucketsForBatchDeletion = 3;
@@ -125,6 +125,12 @@ public class TestS3FileIO {
125125
"s3.delete.batch-size",
126126
Integer.toString(batchDeletionSize));
127127

128+
protected MinIOContainer createMinIOContainer() {
129+
MinIOContainer container = MinioUtil.createContainer();
130+
container.start();
131+
return container;
132+
}
133+
128134
@BeforeEach
129135
public void before() {
130136
s3FileIO = new S3FileIO(() -> s3mock);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.iceberg.aws.s3;
20+
21+
import org.testcontainers.containers.MinIOContainer;
22+
import org.testcontainers.junit.jupiter.Testcontainers;
23+
24+
@Testcontainers
25+
public class TestS3FileIOWithLegacyMinIO extends TestS3FileIO {
26+
@Override
27+
protected MinIOContainer createMinIOContainer() {
28+
MinIOContainer container = MinioUtil.createContainer(MinioUtil.LEGACY_TAG, null);
29+
container.start();
30+
return container;
31+
}
32+
}

aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3RestSigner.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class TestS3RestSigner {
8383

8484
@Container
8585
private static final MinIOContainer MINIO_CONTAINER =
86-
MinioUtil.createContainer(CREDENTIALS_PROVIDER.resolveCredentials());
86+
MinioUtil.createContainer(MinioUtil.LATEST_TAG, CREDENTIALS_PROVIDER.resolveCredentials());
8787

8888
private static Server httpServer;
8989
private static ValidatingSigner validatingSigner;

0 commit comments

Comments
 (0)