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

ENH: automatic credential refresh in kafka source #4258

Conversation

chenqi0805
Copy link
Collaborator

Description

This PR

  • adds support for automatic SASL PLAINTEXT credential refreshment in Kafka source
  • adds integ test on SASL PLAINTEXT

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
@chenqi0805 chenqi0805 force-pushed the enh/credential-refresh-kafka-source branch from 32ced36 to 4311217 Compare March 9, 2024 22:24
Signed-off-by: George Chen <[email protected]>
Signed-off-by: George Chen <[email protected]>
@chenqi0805 chenqi0805 marked this pull request as ready for review March 11, 2024 14:23

final char[] password = basicCredentials.getPassword().toCharArray();
nc.setPassword(password);
}
Copy link
Member

Choose a reason for hiding this comment

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

Are there more conditions here? Perhaps add a log line (WARN) for an else? If we do get another Callback subclass we might have very subtle errors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So all Callbacks are already handled in super.handle(callbacks). Here it is just an overwrite on those two callbacks

Copy link
Member

Choose a reason for hiding this comment

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

I'm not clear on who is overriding this for only these two callbacks?

I'd still tend to think that adding a few lines to log a warning would be helpful in case either of these: 1) We add a bug that adds a new callback elsewhere, but don't support here; or 2) the Kafka implementation changes.

else {
  log.warn("Received an unexpected Callback type {}", callback.getClass());
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

// Used for testing only
protected DynamicBasicCredentialsProvider() {}

public BasicCredentials getBasicCredentials() {
Copy link
Member

Choose a reason for hiding this comment

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

Is DynamicSaslClientCallbackHandler::handle and thus this method called for every interaction with Kafka?

I'm wondering what overhead the read/write lock will have here. And if it is necessary. If we make a request and the username/password is stale, is it that big of a deal? The user needs to setup a proper rotation. Or there will more failures while waiting to get the updated secrets than the difference between two requests to read the value.

Copy link
Collaborator Author

@chenqi0805 chenqi0805 Apr 3, 2024

Choose a reason for hiding this comment

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

Is DynamicSaslClientCallbackHandler::handle and thus this method called for every interaction with Kafka?

Yes.

If we make a request and the username/password is stale, is it that big of a deal?
w/o readwrite lock, I am not sure how stale the credentials could be.

In my POC sasl handshake happens in the background with cadence decoupled from individual API call.

@chenqi0805 chenqi0805 requested a review from dlvenable April 3, 2024 15:56
@chenqi0805 chenqi0805 merged commit 4eeba76 into opensearch-project:main Apr 3, 2024
70 of 74 checks passed
@chenqi0805 chenqi0805 deleted the enh/credential-refresh-kafka-source branch April 3, 2024 19:49
@dlvenable dlvenable added this to the v2.8 milestone Apr 3, 2024
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.

3 participants