You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "nageshvh (via GitHub)" <gi...@apache.org> on 2025/04/05 01:41:55 UTC

[PR] [FLINK-36975][Connectors/AWS] Fix the AWS Config Option AWS_ROLE_CREDENTIALS_PROVIDER_OPTION to pick the right key [flink-connector-aws]

nageshvh opened a new pull request, #196:
URL: https://github.com/apache/flink-connector-aws/pull/196

   ## Purpose of the change
   
   [FLINK-36975][Connectors/AWS] Fix the AWS Config Option AWS_ROLE_CREDENTIALS_PROVIDER_OPTION to pick the right key
   
   https://issues.apache.org/jira/browse/FLINK-36975
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - *Added unit tests*
   
   ## Significant changes
   *(Please check any boxes [x] if the answer is "yes". You can first publish the PR and check them afterwards, for convenience.)*
   - [ ] Dependencies have been added or upgraded
   - [ ] Public API has been changed (Public API is any class annotated with `@Public(Evolving)`)
   - [ ] Serializers have been changed
   - [ ] New feature has been introduced
     - If yes, how is this documented? (not applicable / docs / JavaDocs / not documented)
   


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-36975][Connectors/AWS] Fix the AWS Config Option AWS_ROLE_CREDENTIALS_PROVIDER_OPTION to pick the right key [flink-connector-aws]

Posted by "mohsenrezaeithe (via GitHub)" <gi...@apache.org>.
mohsenrezaeithe commented on code in PR #196:
URL: https://github.com/apache/flink-connector-aws/pull/196#discussion_r2064532605


##########
flink-connector-aws/flink-connector-aws-kinesis-streams/src/main/java/org/apache/flink/connector/kinesis/sink/KinesisStreamsSinkWriter.java:
##########
@@ -167,8 +204,18 @@ class KinesisStreamsSinkWriter<InputT> extends AsyncSinkWriter<InputT, PutRecord
         this.streamArn = streamArn;
         this.metrics = context.metricGroup();
         this.numRecordsOutErrorsCounter = metrics.getNumRecordsOutErrorsCounter();
-        this.httpClient = AWSGeneralUtil.createAsyncHttpClient(kinesisClientProperties);
-        this.kinesisClient = buildClient(kinesisClientProperties, this.httpClient);
+
+        this.kinesisClientProvider = kinesisClientProvider;
+
+        if (kinesisClientProvider != null) {
+            // Use the provided client for testing
+            this.httpClient = null;
+            this.kinesisClient = kinesisClientProvider.get();
+        } else {
+            // Create a new client as before
+            this.httpClient = AWSGeneralUtil.createAsyncHttpClient(kinesisClientProperties);
+            this.kinesisClient = buildClient(kinesisClientProperties, this.httpClient);
+        }

Review Comment:
   Nit: These can be pushed to their own constructors so you don't have to pass in `null` or do a `null` check.



##########
flink-connector-aws/flink-connector-aws-kinesis-streams/src/main/java/org/apache/flink/connector/kinesis/sink/KinesisClientProvider.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.connector.kinesis.sink;
+
+import org.apache.flink.annotation.Internal;
+
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
+
+/**
+ * Provider interface for KinesisAsyncClient instances. This is primarily used for testing to inject
+ * mock clients.
+ */
+@Internal
+interface KinesisClientProvider {

Review Comment:
   Can this also extend `SdkAutoCloseable` so it's inline with the other resource impls?



##########
flink-connector-aws/flink-connector-aws-kinesis-streams/src/main/java/org/apache/flink/connector/kinesis/sink/KinesisStreamsSinkWriter.java:
##########
@@ -244,34 +291,121 @@ private void handleFullyFailedRequest(
 
     @Override
     public void close() {
-        AWSGeneralUtil.closeResources(httpClient, kinesisClient);
+        if (kinesisClientProvider != null) {
+            kinesisClientProvider.close();
+        } else {
+            AWSGeneralUtil.closeResources(httpClient, kinesisClient);

Review Comment:
   IIUC, by having the provider extend `SdkAutoCloseable`, you can pass it as the last parameter to the util for resource cleanup.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-36975][Connectors/AWS] Fix the AWS Config Option AWS_ROLE_CREDENTIALS_PROVIDER_OPTION to pick the right key [flink-connector-aws]

Posted by "jlalwani-amazon (via GitHub)" <gi...@apache.org>.
jlalwani-amazon commented on PR #196:
URL: https://github.com/apache/flink-connector-aws/pull/196#issuecomment-4332133427

   The fix looks correct — `AWS_ROLE_CREDENTIALS_PROVIDER_OPTION` was using `webIdentityTokenFile()` instead of `roleCredentialsProvider()`, generating the wrong config key (`aws.credentials.provider.webIdentityToken.file` instead of `aws.credentials.provider.role.provider`). Clear copy-paste error.
   
   The test coverage is thorough — validates all config option keys against their `AWSConfigConstants` counterparts, which will prevent similar issues in the future.
   
   This is a Blocker that's been open since Dec 2024. Would be great to get it merged.


-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-36975][Connectors/AWS] Fix the AWS Config Option AWS_ROLE_CREDENTIALS_PROVIDER_OPTION to pick the right key [flink-connector-aws]

Posted by "aws-nageshvh (via GitHub)" <gi...@apache.org>.
aws-nageshvh commented on code in PR #196:
URL: https://github.com/apache/flink-connector-aws/pull/196#discussion_r2342430228


##########
flink-connector-aws/flink-connector-aws-kinesis-streams/src/main/java/org/apache/flink/connector/kinesis/sink/KinesisStreamsSinkWriter.java:
##########
@@ -167,8 +204,18 @@ class KinesisStreamsSinkWriter<InputT> extends AsyncSinkWriter<InputT, PutRecord
         this.streamArn = streamArn;
         this.metrics = context.metricGroup();
         this.numRecordsOutErrorsCounter = metrics.getNumRecordsOutErrorsCounter();
-        this.httpClient = AWSGeneralUtil.createAsyncHttpClient(kinesisClientProperties);
-        this.kinesisClient = buildClient(kinesisClientProperties, this.httpClient);
+
+        this.kinesisClientProvider = kinesisClientProvider;
+
+        if (kinesisClientProvider != null) {
+            // Use the provided client for testing
+            this.httpClient = null;
+            this.kinesisClient = kinesisClientProvider.get();
+        } else {
+            // Create a new client as before
+            this.httpClient = AWSGeneralUtil.createAsyncHttpClient(kinesisClientProperties);
+            this.kinesisClient = buildClient(kinesisClientProperties, this.httpClient);
+        }

Review Comment:
   same comment as the others



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [FLINK-36975][Connectors/AWS] Fix the AWS Config Option AWS_ROLE_CREDENTIALS_PROVIDER_OPTION to pick the right key [flink-connector-aws]

Posted by "aws-nageshvh (via GitHub)" <gi...@apache.org>.
aws-nageshvh commented on code in PR #196:
URL: https://github.com/apache/flink-connector-aws/pull/196#discussion_r2342429753


##########
flink-connector-aws/flink-connector-aws-kinesis-streams/src/main/java/org/apache/flink/connector/kinesis/sink/KinesisClientProvider.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.connector.kinesis.sink;
+
+import org.apache.flink.annotation.Internal;
+
+import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
+
+/**
+ * Provider interface for KinesisAsyncClient instances. This is primarily used for testing to inject
+ * mock clients.
+ */
+@Internal
+interface KinesisClientProvider {

Review Comment:
   not sure what has happened here but this PR didn't change this file. This PR - https://github.com/apache/flink-connector-aws/pull/201 already addresses your comments, please check - @mohsenrezaeithe 



##########
flink-connector-aws/flink-connector-aws-kinesis-streams/src/main/java/org/apache/flink/connector/kinesis/sink/KinesisStreamsSinkWriter.java:
##########
@@ -244,34 +291,121 @@ private void handleFullyFailedRequest(
 
     @Override
     public void close() {
-        AWSGeneralUtil.closeResources(httpClient, kinesisClient);
+        if (kinesisClientProvider != null) {
+            kinesisClientProvider.close();
+        } else {
+            AWSGeneralUtil.closeResources(httpClient, kinesisClient);

Review Comment:
   not sure what has happened here but this PR didn't change this file. This PR - https://github.com/apache/flink-connector-aws/pull/201 already addresses your comments, please check - @mohsenrezaeithe 



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org