rkhachatryan commented on code in PR #27026:
URL: https://github.com/apache/flink/pull/27026#discussion_r3769943805


##########
flink-filesystems/flink-s3-fs-base/src/main/java/org/apache/flink/fs/s3/common/writer/RecoverableMultiPartUploadImpl.java:
##########
@@ -322,14 +323,16 @@ private static class UploadTask implements Runnable {
         @Override
         public void run() {
             try {
-                final UploadPartResult result =
+                final UploadPartResponse result =
                         s3AccessHelper.uploadPart(
                                 objectName,
                                 uploadId,
                                 partNumber,
                                 file.getInputFile(),
                                 file.getPos());
-                future.complete(new PartETag(result.getPartNumber(), 
result.getETag()));
+                final CompletedPart completedPart =
+                        
CompletedPart.builder().partNumber(partNumber).eTag(result.eTag()).build();
+                future.complete(completedPart);

Review Comment:
   With SDK v2, this becomes incorrect if user sets 
`s.s3a.checksum.generation=true`. In that case S3 will require checksum per 
part and fail the request because the checksum is missing.



##########
flink-filesystems/flink-s3-fs-hadoop/src/main/java/org/apache/flink/fs/s3/common/token/HadoopDynamicTemporaryAWSCredentialsProvider.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.fs.s3.common.token;
+
+import org.apache.flink.annotation.Internal;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.s3a.auth.NoAwsCredentialsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
+import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
+import software.amazon.awssdk.core.exception.SdkException;
+
+import java.net.URI;
+
+/**
+ * Support dynamic session credentials for authenticating with AWS using SDK 
v2. Please note that
+ * users may reference this class name from configuration property 
fs.s3a.aws.credentials.provider.
+ * Therefore, changing the class name would be a backward-incompatible change.
+ *
+ * <p>This credential provider must not fail during construction, because that 
would break the chain
+ * of credential providers it is registered in. It is, however, expected to 
fail fast from {@link
+ * #resolveCredentials()} by throwing {@link NoAwsCredentialsException} when 
no delegation token
+ * credentials are available yet; the surrounding {@code 
AwsCredentialsProviderChain} treats that as
+ * a signal to move on to the next provider in the chain.
+ */
+@Internal
+public class HadoopDynamicTemporaryAWSCredentialsProvider implements 
AwsCredentialsProvider {
+
+    public static final String NAME = 
HadoopDynamicTemporaryAWSCredentialsProvider.class.getName();
+
+    public static final String COMPONENT = "Dynamic session credentials for 
Flink (SDK v2)";
+
+    private static final Logger LOG =
+            
LoggerFactory.getLogger(HadoopDynamicTemporaryAWSCredentialsProvider.class);
+
+    public HadoopDynamicTemporaryAWSCredentialsProvider() {}
+
+    public HadoopDynamicTemporaryAWSCredentialsProvider(URI uri, Configuration 
conf) {}
+
+    @Override
+    public AwsCredentials resolveCredentials() throws SdkException {
+        S3SessionCredentials credentials = 
AbstractS3DelegationTokenReceiver.getCredentials();

Review Comment:
   This is fragile: this code (`HadoopDynamicTemporaryAWSCredentialsProvider`) 
has only sdk v1 on its classpath; however, `AbstractS3DelegationTokenReceiver` 
imports sdk v2 code.
   If a `AbstractS3DelegationTokenReceiver` / `S3SessionCredentials` method 
that uses sdk v2 classes is called (in the future); that will result in class 
not found exception.
   
   I'm not sure it's worth fixing it though given that we'll have v2 (and 
native) S3.



##########
flink-filesystems/flink-s3-fs-base/src/test/java/org/apache/flink/fs/s3/common/HAApplicationRunOnSeaweedFsS3StoreITCase.java:
##########
@@ -87,7 +88,13 @@ private static List<S3ObjectSummary> 
getObjectsFromApplicationResultStore() {
                 .listObjects(
                         getSeaweedFsContainer().getDefaultBucketName(),
                         createSubPath(CLUSTER_ID, 
APPLICATION_RESULT_STORE_FOLDER))
-                .getObjectSummaries();
+                .getObjectSummaries()
+                .stream()
+                // S3A keeps zero-byte directory markers since Hadoop 3.4
+                // (fs.s3a.directory.marker.retention defaults to "keep"); 
only actual
+                // ApplicationResultStore entries are relevant for the 
assertions.
+                .filter(summary -> !summary.getKey().endsWith("/"))
+                .collect(Collectors.toList());

Review Comment:
   Why can't we keep the current behavior by configuring 
`fs.s3a.directory.marker.retention`?



-- 
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]

Reply via email to