-
Notifications
You must be signed in to change notification settings - Fork 14.7k
KAFKA-18708: Move ScramPublisher to metadata module #20468
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
KAFKA-18708: Move ScramPublisher to metadata module #20468
Conversation
Signed-off-by: see-quick <maros.orsak159@gmail.com>
Signed-off-by: see-quick <maros.orsak159@gmail.com>
Signed-off-by: see-quick <maros.orsak159@gmail.com>
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.
Thanks for the PR. I left a few comments
metadata/src/main/java/org/apache/kafka/metadata/publisher/ScramPublisher.java
Outdated
Show resolved
Hide resolved
metadata/src/main/java/org/apache/kafka/metadata/publisher/ScramPublisher.java
Outdated
Show resolved
Hide resolved
server-common/src/main/java/org/apache/kafka/server/common/CredentialProvider.java
Show resolved
Hide resolved
metadata/src/main/java/org/apache/kafka/metadata/publisher/ScramPublisher.java
Show resolved
Hide resolved
Signed-off-by: see-quick <maros.orsak159@gmail.com>
Signed-off-by: see-quick <maros.orsak159@gmail.com>
… admins scramMechanism) Signed-off-by: see-quick <maros.orsak159@gmail.com>
if (scramDelta != null) { | ||
scramDelta.changes().forEach((mechanism, userChanges) -> { | ||
userChanges.forEach((userName, change) -> { | ||
ScramMechanism internalMechanism = ScramMechanism.forMechanismName(mechanism.mechanismName()); |
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.
Why is this change needed?
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.
ScramMechanism.forMechanismName returns org.apache.kafka.common.security.scram.internals.ScramMechanism
and CredentialProvider methods, i.e., removeCredential and updateCredential need org.apache.kafka.common.security.scram.internals.ScramMechanism
type instead of org.apache.kafka.clients.admin.ScramMechanism
.
scramDelta.changes()
using org.apache.kafka.clients.admin.ScramMechanism
. That's why I have added that here.
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.
I'd prefer if we keep the existing types. Let's focus this PR on the Scala to Java conversion.
If you think you can do further refactoring, we should do that in a separate PR.
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.
I'd prefer if we keep the existing types. Let's focus this PR on the Scala to Java conversion.
Updated.
Signed-off-by: see-quick <maros.orsak159@gmail.com>
FYI: Those failed tests are not related to PR. |
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.
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.
@see-quick thanks for this patch. Sorry for leaving some comments on this merged PR
} | ||
|
||
public void onMetadataUpdate(MetadataDelta delta, MetadataImage newImage) { | ||
String deltaName = "MetadataDelta up to " + newImage.highestOffsetAndEpoch().offset(); |
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.
Could you please create this variable in the catch block? It is only used by the error handler.
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.
I reviewed the PR comparing line by line with the Scala code which had that as well. Not a big deal but we can indeed move that into the catch block.
Looking at the catch block, I wonder if we should have one in FeaturesPublisher
. At a glance, it seems metadataVersionOrThrow()
could throw, or it's terribly named!
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.
Looking at the catch block, I wonder if we should have one in FeaturesPublisher. At a glance, it seems metadataVersionOrThrow() could throw, or it's terribly named!
I prefer to let the caller handle the exception if all FeaturesPublisher
does is call faultHandler.handleFault
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.
My point was consistency. Maybe there's an explanation but looking at these classes they all catch Throwable
and run faultHandler.handleFault()
apart from FeaturesPublisher
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.
@mimaison you are right. +1 to add catch to FeaturesPublisher
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.
onMetadataUpdate(delta, newImage); | ||
} | ||
|
||
public void onMetadataUpdate(MetadataDelta delta, MetadataImage newImage) { |
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.
I'm not sure why we need the onMetadataUpdate(MetadataDelta, MetadataImage)
method. It is only used by BrokerMetadataPublisher#onMetadataUpdate
, but we could just call onMetadataUpdate(MetadataDelta, MetadataImage, LoaderManifest)
instead
@see-quick @mimaison WDYT?
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.
I agree I'm not sure why we have onMetadataUpdate(MetadataDelta, MetadataImage)
. It seems all the callers have a LoaderManifest
instance so they could, and probably should, use onMetadataUpdate(MetadataDelta, MetadataImage, LoaderManifest)
.
I prefer keeping the code "as is" for the Java to Scala conversion. We can tackle this type of refactorings in follow up PRs.
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.
This seems to be the case across most (all?) the *Publisher
classes. So maybe a PR (or set of PRs) addressing them all together would make sense.
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.
So maybe a PR (or set of PRs) addressing them all together would make sense.
+1 to "a PR"
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.
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.
I am considering updating this after all publisher classes have been converted to Java. Or?
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.
Maybe you could fix the ScramPublisher
in PR#20522 and leave the other publishers for the migration :)
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.
Maybe you could fix the ScramPublisher in PR#20522 and leave the other publishers for the migration :)
Yeah, that's a good idea. Will do.
This PR is a follow-up from #20468. Basically makes two things: 1. Moves the variable to the catch block as it is used only there. 2. Refactor FeaturesPublisher to handle exceptions the same as ScramPublisher or other publishers :) Reviewers: Chia-Ping Tsai <chia7712@gmail.com> --------- Signed-off-by: see-quick <maros.orsak159@gmail.com>
This PR is a follow-up from apache#20468. Basically makes two things: 1. Moves the variable to the catch block as it is used only there. 2. Refactor FeaturesPublisher to handle exceptions the same as ScramPublisher or other publishers :) Reviewers: Chia-Ping Tsai <chia7712@gmail.com> --------- Signed-off-by: see-quick <maros.orsak159@gmail.com>
This PR moves the ScramPublisher class from the server metadata package
to the dedicated metadata module. During refactoring, I found out that I
also need to move the CredentialProvider interface to a more appropriate
location in the server common package because
CredentialProvider
is inthe
server
module, and I can't include that module in themetadata
because I would create a circular dependency, i.e.,
server module ←-------------┐ ↓ (depends on). │
(which would make it circular) metadata module------------┘
So I have moved
CredentialProvider
toserver-common
module, andmetadata
module has alreadyserver-common
and thus it's resolved.Reviewers: Mickael Maison mickael.maison@gmail.com