KAFKA-17543: Improve and clarify the error message about generated broker IDs in migration (#17210)

This PR tries to improve the error message when broker.id is set to -1 and ZK migration is enabled. It is not
needed to disable the broker.id.generation.enable option. It is sufficient to just not use it (by not setting
the broker.id to -1).

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Luke Chen <showuon@gmail.com>
This commit is contained in:
Jakub Scholz 2024-09-18 20:45:25 +02:00 committed by Colin P. McCabe
parent c141acb6bf
commit 83091994a6
2 changed files with 3 additions and 3 deletions

View File

@ -853,7 +853,7 @@ class KafkaConfig private(doLog: Boolean, val props: util.Map[_, _])
}
if (brokerIdGenerationEnable) {
if (migrationEnabled) {
require(brokerId != -1, "broker id generation is incompatible with migration to ZK. Please disable it before enabling migration")
require(brokerId >= 0, "broker.id generation is incompatible with ZooKeeper migration. Please stop using it before enabling migration (set broker.id to a value greater or equal to 0).")
}
require(brokerId >= -1 && brokerId <= maxReservedBrokerId, "broker.id must be greater than or equal to -1 and not greater than reserved.broker.max.id")
} else {
@ -973,7 +973,7 @@ class KafkaConfig private(doLog: Boolean, val props: util.Map[_, _])
// ZK-based
if (migrationEnabled) {
require(brokerId >= 0,
"broker broker.id.generation.enable is incompatible with migration to ZK. Please disable it before enabling migration")
"broker.id generation is incompatible with ZooKeeper migration. Please stop using it before enabling migration (set broker.id to a value greater or equal to 0).")
validateQuorumVotersAndQuorumBootstrapServerForMigration()
require(controllerListenerNames.nonEmpty,
s"${KRaftConfigs.CONTROLLER_LISTENER_NAMES_CONFIG} must not be empty when running in ZooKeeper migration mode: ${controllerListenerNames.asJava}")

View File

@ -1891,7 +1891,7 @@ class KafkaConfigTest {
props.setProperty(QuorumConfig.QUORUM_VOTERS_CONFIG, "3000@localhost:9093")
props.setProperty(KRaftConfigs.CONTROLLER_LISTENER_NAMES_CONFIG, "CONTROLLER")
assertEquals(
"requirement failed: broker id generation is incompatible with migration to ZK. Please disable it before enabling migration",
"requirement failed: broker.id generation is incompatible with ZooKeeper migration. Please stop using it before enabling migration (set broker.id to a value greater or equal to 0).",
assertThrows(classOf[IllegalArgumentException], () => KafkaConfig.fromProps(props)).getMessage)
}