-
Notifications
You must be signed in to change notification settings - Fork 68
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
Conversation
408d60c
to
6efbfaa
Compare
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
Updated description wrt testing |
} | ||
} | ||
|
||
public static String getMechanismNameForClassLoader(ClassLoader classLoader) { |
There was a problem hiding this comment.
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.
…der based on ClassLoader
6efbfaa
to
f3069d3
Compare
Issue #, if available:
#36
Description of changes:
This change fixes the classloader issue experienced in this issue. I have introduced a new
SaslClientFactory
calledClassLoaderAwareIAMSaslClientFactory
registered under theAWS_MSK_IAM
mechanism. The existingIAMSaslClientFactory
has been moved to a new mechanism nameAWS_MSK_IAM.<classloader>
. EachIAMLoginModule
will register both mechanisms, we will end up with oneClassLoaderAwareIAMSaslClientFactory
per JVM andn
copies ofIAMSaslClientFactory
,n
equals the number of ClassLoaders used.ClassLoaderAwareIAMSaslClientFactory
picks the correctIAMSaslClientFactory
based on the classloader of theCallbackHandler
For single classloader environments, there will be 1
ClassLoaderAwareIAMSaslClientFactory
and 1IAMSaslClientFactory
. 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 ofIAMSaslClientFactory
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.