-
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?
import org.apache.kafka.metadata.publisher.AclPublisher | ||
import org.apache.kafka.security.CredentialProvider | ||
import org.apache.kafka.metadata.publisher.{AclPublisher, ScramPublisher} | ||
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.
Can we move this with the other org.apache.kafka.server.common
import below?
import org.apache.kafka.raft.QuorumConfig | ||
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.
Can we move this with the other org.apache.kafka.server.common import below?
@@ -28,7 +28,7 @@ import org.apache.kafka.common.security.token.delegation.internals.DelegationTok | |||
import org.apache.kafka.common.utils.Time | |||
import org.apache.kafka.coordinator.group.GroupCoordinator | |||
import org.apache.kafka.metadata.{BrokerState, MetadataCache} | |||
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.
Can we move this with the other org.apache.kafka.server.common import below?
@@ -37,7 +37,7 @@ import org.apache.kafka.common.utils.{Exit, Time, Utils} | |||
import org.apache.kafka.common.{TopicPartition, Uuid, protocol} | |||
import org.apache.kafka.raft.errors.NotLeaderException | |||
import org.apache.kafka.raft.{Batch, BatchReader, Endpoints, LeaderAndEpoch, QuorumConfig, RaftClient} | |||
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.
Can we move this with the other org.apache.kafka.server.common import below?
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'll stop noting it from here, the same applies to all files/imports
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?
faultHandler.handleFault("Uncaught exception while publishing SCRAM changes from " + deltaName, t); | ||
} | ||
} | ||
} |
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.
Can we add a newline at the end of the file?
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 wonder if we should keep the package and just change the module.
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{ }
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.