Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS: Enable Adaptive Retries for AWS KMS client #11420

Merged
merged 5 commits into from
Dec 11, 2024

Conversation

hsiang-c
Copy link
Contributor

@hsiang-c hsiang-c commented Oct 29, 2024

  • We're reaching the limit of AWS KMS requests per AWS account quota and we'd like to enable retry in KMS client to be more resilient to failures.
  • This PR is similar to AWS: Set better defaults for S3 retry behaviour #11052 but using the SDK provided RetryMode.
  • I didn't choose RetryPolicy b/c it is deprecated.

@github-actions github-actions bot added the AWS label Oct 29, 2024
@hsiang-c
Copy link
Contributor Author

@nastra @jackye1995 please review it when you have time, thanks!

Copy link
Member

@jbonofre jbonofre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. I just left a nit about pointing to the documentation (especially about retry mode accepted values).

this.kmsRetryMode = RetryMode.valueOf(KMS_RETRY_MODE_DEFAULT);
}

public KmsClientProperties(Map<String, String> properties) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would add the link to AWS configBuilder configuration, especially about retry mode (to know the accepted values for retry mode).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbonofre Thank you for your review! I linked to both RetryMode and ClientOverrideConfiguration.

@danielcweeks
Copy link
Contributor

Is this really necessary to make configurable? Why shouldn't we just set ADAPTIVE_V2 as the default when constructing the client? This is only for retry behavior, I'm not sure it's worth even making it an option.

@hsiang-c
Copy link
Contributor Author

hsiang-c commented Nov 7, 2024

@danielcweeks Thank you for your review.

Is this really necessary to make configurable?

I am also working on an enhancement to Iceberg S3 doc: #11321, which makes me think users might want to configure AWS service clients with available configurations provided by the client libraries.

This is only for retry behavior, I'm not sure it's worth even making it an option.

Got it, I have no problem with setting ADAPTIVE_V2 as the default, though the default mode is LEGACY according to AWS Java V2 SDK.

Is having too many options a concern to you? I'd like to learn more about your thoughts.

Thanks again for your time.

@danielcweeks
Copy link
Contributor

Is having too many options a concern to you? I'd like to learn more about your thoughts.

I feel like the proliferation of options is not a good thing unless there's real value being added. This doesn't seem to be one of those cases. Rather than adding a lot of boilerplate configuration, I would suggest just setting this at ADAPTIVE_V2, which seems to be an improvement upon the legacy default.

@hsiang-c
Copy link
Contributor Author

hsiang-c commented Nov 8, 2024

Thanks for your feedback @danielcweeks Please take a look again.

If you still have time, I have another PR for you #11321

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hsiang-c I agree with @danielcweeks that we need to be cautious when adding new properties, specifically what that means is evaluating if it's a valuable knob that's worth adding. In this case we know that we generally want to retry when throttled and the recommended strategy is adaptive so the produced clients should just do that without exposing things to users.

Overall this PR looks to be a good direction, just had a comment that I don't think the public KmsClientProperties class is needed at the moment.

import software.amazon.awssdk.core.retry.RetryMode;
import software.amazon.awssdk.services.kms.KmsClientBuilder;

public class KmsClientProperties implements Serializable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this class considering there's no separate properties we're introducing for KMS and the fact that it may make sense to also apply ADAPTIVE_V2 for Glue client as well (not needed in this PR, but down the line we could just use that)? Just don't want to avoid public properties classes until they're really necessary

I think an applyRetryConfigurations in the existing AwsClientProperties also would work well since that class is meant for generalizing across the different AWS clients.

Copy link
Contributor Author

@hsiang-c hsiang-c Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amogh-jahagirdar Thank you for your feedback.

Making applyRetryConfigurations as part of AwsClientProperties makes sense to me.

awsClientProperties.applyRetryConfigurations(builder);
RetryMode retryPolicy = builder.overrideConfiguration().retryMode().get();

assertThat(retryPolicy).as("retry mode was not set").isEqualTo(RetryMode.ADAPTIVE_V2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could we clean up this error message to be "Retry mode should be ADAPTIVE_V2"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this one.

@amogh-jahagirdar amogh-jahagirdar self-requested a review December 10, 2024 04:38
@amogh-jahagirdar amogh-jahagirdar dismissed their stale review December 10, 2024 04:39

accidentally approved, there's some things I think we should cleanup before

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hsiang-c I think this is very close just some java docs that I think should be cleaned up before merging

Comment on lines 159 to 166
/**
* Set ADAPTIVE_V2 <a
* href="https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/retry/RetryMode.html">RetryMode</a>
* for an AWS client builder.
*
* <p>For more details, see
* https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/core/client/config/ClientOverrideConfiguration.Builder.html#retryStrategy(software.amazon.awssdk.core.retry.RetryMode)
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we structure this JavaDoc similar to the the other apply configuration methods? e.g. checkout the java doc in applyClientCredentialConfigurations or applyClientRegionConfiguration

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hsiang-c , this looks great to me now!

@amogh-jahagirdar
Copy link
Contributor

amogh-jahagirdar commented Dec 11, 2024

I'll go ahead and merge, thanks @hsiang-c and thanks @jbonofre for reviewing

@amogh-jahagirdar amogh-jahagirdar merged commit ff81344 into apache:main Dec 11, 2024
49 checks passed
@amogh-jahagirdar amogh-jahagirdar changed the title AWS: Enable RetryMode for AWS KMS client AWS: Enable Adaptive Retries for AWS KMS client Dec 11, 2024
@hsiang-c
Copy link
Contributor Author

Thank you @amogh-jahagirdar

@hsiang-c hsiang-c deleted the aws_kms_retry branch December 11, 2024 02:18
zachdisc pushed a commit to zachdisc/iceberg that referenced this pull request Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants