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

Adding a proxy to delegate to appropriate IAMSaslClientProvider based on ClassLoader #82

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

dannycranmer
Copy link
Contributor

@dannycranmer dannycranmer commented Oct 10, 2022

Issue #, if available:

#36

Description of changes:

This change fixes the classloader issue experienced in this issue. I have introduced a new SaslClientFactory called ClassLoaderAwareIAMSaslClientFactory registered under the AWS_MSK_IAM mechanism. The existing IAMSaslClientFactory has been moved to a new mechanism name AWS_MSK_IAM.<classloader>. Each IAMLoginModule will register both mechanisms, we will end up with one ClassLoaderAwareIAMSaslClientFactory per JVM and n copies of IAMSaslClientFactory, n equals the number of ClassLoaders used.

ClassLoaderAwareIAMSaslClientFactory picks the correct IAMSaslClientFactory based on the classloader of the CallbackHandler

For single classloader environments, there will be 1 ClassLoaderAwareIAMSaslClientFactory and 1 IAMSaslClientFactory. We will incur a negligible performance hit delegating from one to the other.

Testing

I have tested against MSK using a Flink cluster running on EC2 box. I verified this issue resolves issue #36. I am waiting for additional test feedback from other stakeholders, and am hoping that this can be verified against MSK e2e tests.

Concerns:

Since we register n copies of IAMSaslClientFactory there is an opportunity for this to infinitely grow and leak, for example if a Flink job is continuously failing over. However, in this situation the job is already broken and this tradeoff might be acceptable against the current state, where multi classloader environments are not supported.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@hlteoh37
Copy link

Have we tested that this works to resolve the specific failure mode specified here? #36 (comment)

If so, we might want to mention it in the overview

Copy link

@hlteoh37 hlteoh37 left a comment

Choose a reason for hiding this comment

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

Code changes LGTM

Copy link

@iemre iemre left a comment

Choose a reason for hiding this comment

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

code looks good to me.

Agree with @hlteoh37 that it'd be good to end-to-end test the new mechanism. I trust you have already done this but might be good to share the results in PR description.

CallbackHandler cbh) throws SaslException {
String mechanismName = getMechanismNameForClassLoader(cbh.getClass().getClassLoader());

// Creat a client by delegating to the SaslClientFactory for the classloader of the CallbackHandler
Copy link

Choose a reason for hiding this comment

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

typo

@dannycranmer
Copy link
Contributor Author

dannycranmer commented Oct 13, 2022

Updated description wrt testing

}
}

public static String getMechanismNameForClassLoader(ClassLoader classLoader) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you do create a IAMClassAwareLoginModule, this static method could be a utility static method in that class.

@sayantacC sayantacC merged commit 9269ee2 into aws:main Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants