KAFKA-15450 Don't allow ZK migration with JBOD (#14367)

Reviewers: Ron Dagostino <rndgstn@gmail.com>
This commit is contained in:
David Arthur 2023-09-12 10:27:50 -04:00
parent ec1ab53dcd
commit 04866a2a08
2 changed files with 13 additions and 0 deletions

View File

@ -2248,6 +2248,7 @@ class KafkaConfig private(doLog: Boolean, val props: java.util.Map[_, _], dynami
s"${KafkaConfig.ControllerListenerNamesProp} must not be empty when running in ZooKeeper migration mode: ${controllerListenerNames.asJava}")
require(interBrokerProtocolVersion.isMigrationSupported, s"Cannot enable ZooKeeper migration without setting " +
s"'${KafkaConfig.InterBrokerProtocolVersionProp}' to 3.4 or higher")
require(logDirs.size == 1, "Cannot enable ZooKeeper migration when multiple log directories (aka JBOD) are in use.")
} else {
// controller listener names must be empty when not in KRaft mode
require(controllerListenerNames.isEmpty,

View File

@ -1677,6 +1677,18 @@ class KafkaConfigTest {
KafkaConfig.fromProps(props)
}
@Test
def testMigrationCannotBeEnabledWithJBOD(): Unit = {
val props = TestUtils.createBrokerConfig(1, TestUtils.MockZkConnect, port = TestUtils.MockZkPort, logDirCount = 2)
props.setProperty(KafkaConfig.MigrationEnabledProp, "true")
props.setProperty(KafkaConfig.QuorumVotersProp, "3000@localhost:9093")
props.setProperty(KafkaConfig.ControllerListenerNamesProp, "CONTROLLER")
assertEquals(
"requirement failed: Cannot enable ZooKeeper migration when multiple log directories (aka JBOD) are in use.",
assertThrows(classOf[IllegalArgumentException], () => KafkaConfig.fromProps(props)).getMessage)
}
@Test
def testMigrationEnabledKRaftMode(): Unit = {
val props = new Properties()