You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/12/08 00:15:30 UTC
[GitHub] [kafka] mumrah opened a new pull request, #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
mumrah opened a new pull request, #12965:
URL: https://github.com/apache/kafka/pull/12965
Prior to starting a KIP-866 migration, the ZK brokers must register themselves with the active KRaft controller. The controller waits for all brokers to register in order to verify that all the brokers can
A) Communicate with the quorum
B) Have the migration config enabled
C) Have the proper IBP set
This patch uses the new `isMigratingZkBroker` field in BrokerRegistrationRequest and RegisterBrokerRecord. The type was changed from `int8` to `bool` for BrokerRegistrationRequest (a mistake from #12860). The ZK brokers use the existing BrokerLifecycleManager class to register and heartbeat with the controllers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe commented on PR #12965:
URL: https://github.com/apache/kafka/pull/12965#issuecomment-1343489745
Thanks for the PR!
> This patch uses the new isMigratingZkBroker field in BrokerRegistrationRequest and RegisterBrokerRecord. The type was changed from int8 to bool for BrokerRegistrationRequest (a mistake from https://github.com/apache/kafka/pull/12860).
I think there is one other major mistake we made there: this should not be a tagged field, but should be a new version of the RPC. The reason is because this is not safe to ignore. If an old controller treats this broker like an ordinary KRaft broker, that would be a big mistake.
While a new verison of `BrokerRegistrationRequest` may seem difficult to implement, I think it's actually simpler than it seems. The `NetworkClient` itself should have the `ApiVersions` of the controller available. It gets this when it first connects to the controller. So we can simply take the max of the registration version our broker supports, and the registration version the controller supports.
There is already code to do all this in `BrokerRegistrationRequest#Builder`. The only complication is if you need to set `isZkBroker` you need to set `BrokerRegistrationRequest#Builder.oldestAllowedVersion` to 1 rather than 0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043908893
##########
core/src/main/scala/kafka/server/KafkaConfig.scala:
##########
@@ -2230,8 +2230,15 @@ class KafkaConfig private(doLog: Boolean, val props: java.util.Map[_, _], dynami
validateAdvertisedListenersNonEmptyForBroker()
} else {
// ZK-based
- // controller listener names must be empty when not in KRaft mode
- require(controllerListenerNames.isEmpty, s"${KafkaConfig.ControllerListenerNamesProp} must be empty when not running in KRaft mode: ${controllerListenerNames.asJava}")
+ if (migrationEnabled) {
+ validateNonEmptyQuorumVotersForKRaft()
+ require(controllerListenerNames.nonEmpty,
Review Comment:
this seems like a bug. in migration mode you want it to be non-empty, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] mumrah commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
mumrah commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043473436
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -81,6 +84,19 @@ object KafkaServer {
clientConfig
}
+ def zkClient(name: String, time: Time, config: KafkaConfig, zkClientConfig: ZKClientConfig): KafkaZkClient = {
Review Comment:
This was meant to go in with #12946. It's a small refactor to make it easy to create a KafkaZkClient from ControllerServer (which is TBD)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043910049
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -81,6 +84,19 @@ object KafkaServer {
clientConfig
}
+ def zkClient(name: String, time: Time, config: KafkaConfig, zkClientConfig: ZKClientConfig): KafkaZkClient = {
Review Comment:
Hmm. Maybe I'm missing something, but I don't see any relationship with `KafkaServer`. Why put this in `KafkaServer.scala`? Can this be a `static` function in `KafkaZkClient.scala`? (aka "function on `object KafkaZkClient`")?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043911086
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -453,6 +534,16 @@ class KafkaServer(
dynamicConfigManager = new ZkConfigManager(zkClient, dynamicConfigHandlers)
dynamicConfigManager.startup()
+ if (config.migrationEnabled && lifecycleManager != null) {
+ lifecycleManager.initialCatchUpFuture.whenComplete { case (_, t) =>
+ if (t != null) {
+ fatal("Encountered an exception when waiting to catch up with KRaft metadata log", t)
+ shutdown()
+ } else {
+ lifecycleManager.setReadyToUnfence()
Review Comment:
can we have a log message here (INFO) ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] mumrah commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
mumrah commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1044612119
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -690,6 +772,14 @@ class KafkaServer(
_brokerState = BrokerState.PENDING_CONTROLLED_SHUTDOWN
+ if (config.migrationEnabled && lifecycleManager != null) {
+ // TODO KAFKA-14447 Only use KRaft controlled shutdown (when in migration mode)
Review Comment:
Right, we'll read this information from MetadataCache once we get the UMR changes merged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe merged pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe merged PR #12965:
URL: https://github.com/apache/kafka/pull/12965
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043911867
##########
clients/src/main/resources/common/message/BrokerRegistrationRequest.json:
##########
@@ -51,7 +51,7 @@
},
{ "name": "Rack", "type": "string", "versions": "0+", "nullableVersions": "0+",
"about": "The rack which this broker is in." },
- { "name": "IsMigratingZkBroker", "type": "int8", "versions": "0+", "taggedVersions": "0+", "tag": 0, "ignorable": true,
+ { "name": "IsMigratingZkBroker", "type": "bool", "versions": "0+", "taggedVersions": "0+", "tag": 0, "ignorable": true,
Review Comment:
see my comment in the main PR conversation thread: this should not be tagged and we need a new version of the rpc ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] mumrah commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
mumrah commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1044606857
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -81,6 +84,19 @@ object KafkaServer {
clientConfig
}
+ def zkClient(name: String, time: Time, config: KafkaConfig, zkClientConfig: ZKClientConfig): KafkaZkClient = {
+ val secureAclsEnabled = config.zkEnableSecureAcls
+ val isZkSecurityEnabled = JaasUtils.isZkSaslEnabled || KafkaConfig.zkTlsClientAuthEnabled(zkClientConfig)
+
+ if (secureAclsEnabled && !isZkSecurityEnabled)
+ throw new java.lang.SecurityException(s"${KafkaConfig.ZkEnableSecureAclsProp} is true, but ZooKeeper client TLS configuration identifying at least $KafkaConfig.ZkSslClientEnableProp, $KafkaConfig.ZkClientCnxnSocketProp, and $KafkaConfig.ZkSslKeyStoreLocationProp was not present and the " +
Review Comment:
Thanks! This was just a copy/paste refactor. I wonder how long this has been broken 😅
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -81,6 +84,19 @@ object KafkaServer {
clientConfig
}
+ def zkClient(name: String, time: Time, config: KafkaConfig, zkClientConfig: ZKClientConfig): KafkaZkClient = {
Review Comment:
This was just relocated from elsewhere in KafkaServer. I do agree it's kind of out of place. I'll move it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] mumrah commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
mumrah commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1044604344
##########
core/src/main/scala/kafka/server/KafkaConfig.scala:
##########
@@ -2230,8 +2230,15 @@ class KafkaConfig private(doLog: Boolean, val props: java.util.Map[_, _], dynami
validateAdvertisedListenersNonEmptyForBroker()
} else {
// ZK-based
- // controller listener names must be empty when not in KRaft mode
- require(controllerListenerNames.isEmpty, s"${KafkaConfig.ControllerListenerNamesProp} must be empty when not running in KRaft mode: ${controllerListenerNames.asJava}")
+ if (migrationEnabled) {
+ validateNonEmptyQuorumVotersForKRaft()
+ require(controllerListenerNames.nonEmpty,
Review Comment:
oh, i typoed the description. the code is correct i think: `validateNonEmptyQuorumVotersForKRaft` `controllerListenerNames.nonEmpty`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] mumrah commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
mumrah commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043473436
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -81,6 +84,19 @@ object KafkaServer {
clientConfig
}
+ def zkClient(name: String, time: Time, config: KafkaConfig, zkClientConfig: ZKClientConfig): KafkaZkClient = {
Review Comment:
This is coming from #12946 which is getting merged first
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043907559
##########
core/src/main/scala/kafka/server/BrokerLifecycleManager.scala:
##########
@@ -53,7 +53,8 @@ import scala.jdk.CollectionConverters._
*/
class BrokerLifecycleManager(val config: KafkaConfig,
Review Comment:
can you use the standard style of
```
foo(
bar
baz
quux
) {
}
```
this code was written before we adopted that but if we're adding new parameters let's format it that way to avoid having so much indentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] cmccabe commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
cmccabe commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1043911573
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -690,6 +772,14 @@ class KafkaServer(
_brokerState = BrokerState.PENDING_CONTROLLED_SHUTDOWN
+ if (config.migrationEnabled && lifecycleManager != null) {
+ // TODO KAFKA-14447 Only use KRaft controlled shutdown (when in migration mode)
Review Comment:
so the TODO here is that we need to check if the controller is a kraft one?
fair enough.
I keep thinking that info should be in the metadata cache ... I guess we can do that in a follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [kafka] mimaison commented on a diff in pull request #12965: KAFKA-14448 Let ZK brokers register with KRaft controller
Posted by GitBox <gi...@apache.org>.
mimaison commented on code in PR #12965:
URL: https://github.com/apache/kafka/pull/12965#discussion_r1044340329
##########
metadata/src/main/java/org/apache/kafka/metadata/BrokerRegistration.java:
##########
@@ -234,6 +277,7 @@ public String toString() {
bld.append(", rack=").append(rack);
bld.append(", fenced=").append(fenced);
bld.append(", inControlledShutdown=").append(inControlledShutdown);
+ bld.append(", isMigratingZkBroker=").append(isMigratingZkBroker);
Review Comment:
We need to update `BrokerRegistrationTest.testToString()` too
##########
core/src/main/scala/kafka/server/KafkaServer.scala:
##########
@@ -81,6 +84,19 @@ object KafkaServer {
clientConfig
}
+ def zkClient(name: String, time: Time, config: KafkaConfig, zkClientConfig: ZKClientConfig): KafkaZkClient = {
+ val secureAclsEnabled = config.zkEnableSecureAcls
+ val isZkSecurityEnabled = JaasUtils.isZkSaslEnabled || KafkaConfig.zkTlsClientAuthEnabled(zkClientConfig)
+
+ if (secureAclsEnabled && !isZkSecurityEnabled)
+ throw new java.lang.SecurityException(s"${KafkaConfig.ZkEnableSecureAclsProp} is true, but ZooKeeper client TLS configuration identifying at least $KafkaConfig.ZkSslClientEnableProp, $KafkaConfig.ZkClientCnxnSocketProp, and $KafkaConfig.ZkSslKeyStoreLocationProp was not present and the " +
Review Comment:
It's missing curly brackets around some variables so this would not print them correctly
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org