-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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-18530 Remove ZooKeeperInternals #18641
Conversation
@@ -16,12 +16,11 @@ | |||
*/ | |||
package org.apache.kafka.server.config; | |||
|
|||
public class ZooKeeperInternals { | |||
public class KraftInternals { |
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 don't think this name makes sense - there's nothing specific to kraft in this code. Can we move this constant to one of the quota classes and have the others reference it from there?
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.
Removing this would affect the default username and default client-id. Since this is a breaking change, I suggest we maintain consistency by keeping these default values. 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.
@m1a2st Could you please clean up the usage of ZooKeeperInternals.DEFAULT_STRING
first? We are currently using ZooKeeperInternals.DEFAULT_STRING
as a specific string for compatibility with the zk handler (QuotaConfigHandler). Since #18617 will remove QuotaConfigHandler
, the kraft ClientQuotaMetadataManager
no longer needs to use ZooKeeperInternals.DEFAULT_STRING
.
After addressing above comment, we can move <default>
to be a internal constant of ClientQuotaManager
to ensure the compatibility of metrics kafka.server:type={Produce|Fetch},user=([-.\w]+),client-id=([-.\w]+)
@@ -147,13 +148,13 @@ class ClientQuotaMetadataManager(private[metadata] val quotaManagers: QuotaManag | |||
// Convert entity into Options with sanitized values for QuotaManagers | |||
val (sanitizedUser, sanitizedClientId) = quotaEntity match { | |||
case UserEntity(user) => (Some(Sanitizer.sanitize(user)), None) | |||
case DefaultUserEntity => (Some(ZooKeeperInternals.DEFAULT_STRING), None) | |||
case DefaultUserEntity => (Some(ClientQuotaManager.DefaultString), None) |
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.
We should use Option[BaseUserEntity] instead of a string. As mentioned previously (#18641 (comment)), there's no need for a specific string to represent the "default" value.
if (brokerId == ZooKeeperInternals.DEFAULT_STRING) | ||
brokerConfig.dynamicConfig.updateDefaultConfig(properties) | ||
else if (brokerConfig.brokerId == brokerId.trim.toInt) { | ||
if (brokerConfig.brokerId == brokerId.trim.toInt) { |
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.
We must handle the "default" configs when the broker id is "empty"
@m1a2st could you please rebase code to include the recent flaky fixes? |
): Option[ClientQuotaEntity.ConfigEntity] = { | ||
if (sanitizedClientId.isEmpty) | ||
None | ||
else if (sanitizedClientId.get.name() == DefaultString) |
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 kraft, we don't use <default>
so this check is weird. If this is used to fix test, then maybe we should revise the test
else if (sanitizedClientId.get.name() == DefaultString) | ||
Some(DefaultClientIdEntity) | ||
else { | ||
val clientId = sanitizedClientId.map(s => Sanitizer.desanitize(s.name())) |
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.
we should handle the ClientIdEntity
only.
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.
@m1a2st thanks for this patch
@@ -48,13 +48,6 @@ import scala.collection._ | |||
import scala.jdk.CollectionConverters._ | |||
|
|||
/** | |||
* Dynamic broker configurations are stored in ZooKeeper and may be defined at two levels: |
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 kraft mode, the two levels are still existent. could you please revise it instead of removing 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.
Heya @m1a2st! I have a follow-up ask, while the two levels are still present they will no longer be under the path specified in this file since the path is ZK-specific. As long as we don't use this comment to generate documentation I am okay with this being removed in a subsequent PR. However, if we use this file to generate documentation could you change this as part of this 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 think those comments in DynamicBrokerConfig are not used to generate documentation, but it will be better to correct it - as least, the description about zk path must be removed.
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.
Okay, then I will review once they have been changed 😊!
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.
core/src/main/scala/kafka/server/metadata/ClientQuotaMetadataManager.scala
Outdated
Show resolved
Hide resolved
Thanks for @chia7712 review, addressed all comments. |
case DefaultUserEntity => | ||
(Some(ClientQuotaManager.DefaultUserEntity), None) | ||
case ClientIdEntity(clientId) => | ||
(None, Some(ClientQuotaManager.ClientIdEntity(Sanitizer.sanitize(clientId)))) |
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.
Do we need to sanitize data in kraft mode? the zk path is gone so we don't need to align the data for zk anymore.
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 sanitize
method, It deal with *
and +
symbols. Therefore, I think it is not only handling matters related to Zookeeper.
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.
After under discussion, We should remove this sanitize
, it is unused in this path.
val clientIdEntity = sanitizedClientId.map { | ||
case ZooKeeperInternals.DEFAULT_STRING => DefaultClientIdEntity | ||
case _ => ClientIdEntity(clientId.getOrElse(throw new IllegalStateException("Client-id not provided"))) | ||
val clientIdEntity = clientEntity match { |
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.
we don't need this conversion, right?
@m1a2st please file a PR for 4.0 as there are some conflicts |
Since zk has been removed in 4.0, config handlers no longer need to handle the "<default>" value. This PR streamlines the config update process by eliminating the unnecessary string checks for "<default>" Reviewers: Christo Lolov <[email protected]>, Ismael Juma <[email protected]>, Chia-Ping Tsai <[email protected]>
I backport some cleanup to eliminate the conflicts |
Jira: https://issues.apache.org/jira/browse/KAFKA-18530
Since Kafka 4.0 has deprecated ZooKeeper, we should also remove the
ZooKeeperInternals
class. However, we need to maintain backward compatibility for metric names.Committer Checklist (excluded from commit message)