KAFKA-18530 Remove ZooKeeperInternals#18641
Conversation
| package org.apache.kafka.server.config; | ||
|
|
||
| public class ZooKeeperInternals { | ||
| public class KraftInternals { |
There was a problem hiding this comment.
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.
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.
@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]+)
| 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.
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.
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.
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.
we should handle the ClientIdEntity only.
| 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.
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.
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.
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.
Okay, then I will review once they have been changed 😊!
|
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.
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.
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.
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.
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 <lolovc@amazon.com>, Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
I backport some cleanup to eliminate the 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 <lolovc@amazon.com>, Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
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 <lolovc@amazon.com>, Ismael Juma <ismael@juma.me.uk>, Chia-Ping Tsai <chia7712@gmail.com>
Jira: https://issues.apache.org/jira/browse/KAFKA-18530
Since Kafka 4.0 has deprecated ZooKeeper, we should also remove the
ZooKeeperInternalsclass. However, we need to maintain backward compatibility for metric names.Committer Checklist (excluded from commit message)