-
Notifications
You must be signed in to change notification settings - Fork 14.6k
KAFKA-18706: 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
base: trunk
Are you sure you want to change the base?
Conversation
Signed-off-by: see-quick <[email protected]>
Signed-off-by: see-quick <[email protected]>
Signed-off-by: see-quick <[email protected]>
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
@@ -44,7 +44,7 @@ import org.apache.kafka.common.security.auth.SecurityProtocol | |||
import org.apache.kafka.common.utils.{KafkaThread, LogContext, Time, Utils} | |||
import org.apache.kafka.common.{Endpoint, KafkaException, MetricName, Reconfigurable} | |||
import org.apache.kafka.network.{ConnectionQuotaEntity, ConnectionThrottledException, SocketServerConfigs, TooManyConnectionsException} | |||
import org.apache.kafka.security.CredentialProvider | |||
import org.apache.kafka.server.common.CredentialProvider |
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.
nit: We try to order import alphabetically, can we move this 1 line down?
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.
Interestingly, checkstyle
allows such a change. Should we also update the spotless or checkstyle configuration to address this problem? :). In this PR, I will update it manually now, but for next time, to avoid it.
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 believe we don't enforce checkstyle on Scala code yet as it would fail on many files and fixing it would create a lot of noise.
String deltaName = "MetadataDelta up to " + newImage.highestOffsetAndEpoch().offset(); | ||
try { | ||
// Apply changes to SCRAM credentials. | ||
Optional.ofNullable(delta.scramDelta()).ifPresent(scramDelta -> { |
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 wonder if doing:
ScramDelta scramDelta = delta.scramDelta();
if (scramDelta != null) {
is just more readable. 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.
Sure.
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
Outdated
Show resolved
Hide resolved
scramDelta.changes().forEach((mechanism, userChanges) -> { | ||
userChanges.forEach((userName, change) -> { |
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.
In both cases, the body of the block is a single expression, so we can remove the brackets{ }
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.
Also, this could be added to checkstyle, I assume. Updated.
Signed-off-by: see-quick <[email protected]>
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.