GeezerVison is showing github.com — KAFKA-20901: Enforce cordoned log directories configured with relativ… · coderbruis/kafka@a2b91b7
File treeExpand file treeCollapse file tree Open diff view settings test/scala/unit/kafka/server
server-common/src/main/java/org/apache/kafka/server/config main/java/org/apache/kafka/server test/java/org/apache/kafka/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: core/src/main/scala/kafka/server/KafkaConfig.scala +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -289,8 +289,12 @@ class KafkaConfig private(doLog: Boolean, val props: util.Map[_, _], enforceProv | 289 | 289 | if (cordonedLogDirs.contains(ServerLogConfigs.CORDONED_LOG_DIRS_ALL)) { | 290 | 290 | require(cordonedLogDirs.size == 1, s"When ${ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG} is set to ${ServerLogConfigs.CORDONED_LOG_DIRS_ALL}, it must not contain other values") | 291 | 291 | } else { | 292 | | - val unknownLogDirs = cordonedLogDirs.asScala.filter(!logDirs().contains(_)) | 293 | | - require(unknownLogDirs.isEmpty, s"All entries in ${ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG} must be present in ${ServerLogConfigs.LOG_DIRS_CONFIG} or ${ServerLogConfigs.LOG_DIR_CONFIG}. Missing entries : ${unknownLogDirs.mkString(", ")}") | | 292 | + val absoluteLogDirSet = absoluteLogDirs().asScala.toSet | | 293 | + val unknownLogDirs = cordonedLogDirs.asScala.zip(absoluteCordonedLogDirs().asScala).collect { | | 294 | + case (cordonedLogDir, absoluteCordonedLogDir) if !absoluteLogDirSet.contains(absoluteCordonedLogDir) => | | 295 | + if (cordonedLogDir == absoluteCordonedLogDir) cordonedLogDir else s"$cordonedLogDir (absolute path: $absoluteCordonedLogDir)" | | 296 | + } | | 297 | + require(unknownLogDirs.isEmpty, s"All entries in ${ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG} must match ${ServerLogConfigs.LOG_DIRS_CONFIG} or ${ServerLogConfigs.LOG_DIR_CONFIG} entries by absolute path. Missing entries: ${unknownLogDirs.mkString(", ")}") | 294 | 298 | } | 295 | 299 | } | 296 | 300 |
| |
Collapse file Copy file name to clipboardExpand all lines: core/src/test/scala/unit/kafka/server/BrokerLifecycleManagerTest.scala +33Lines changed: 33 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 |
| 18 | 18 | package kafka.server | 19 | 19 |
| | 20 | +import java.io.File | 20 | 21 | import java.util | 21 | 22 | import java.util.{Collections, OptionalLong, Properties} | 22 | 23 | import kafka.utils.TestUtils | @@ -303,6 +304,38 @@ class BrokerLifecycleManagerTest { | 303 | 304 | assertEquals(1200L, manager.brokerEpoch) | 304 | 305 | } | 305 | 306 |
| | 307 | + @Test | | 308 | + def testRelativeCordonedLogDirsIncludedInHeartbeatAfterInitialCatchUp(): Unit = { | | 309 | + val relativeLogDir = "relative-log-dir" | | 310 | + val logDirId = Uuid.fromString("ad5FLIeCTnaQdai5vOjeng") | | 311 | + val props = configProperties | | 312 | + props.setProperty(ServerLogConfigs.LOG_DIRS_CONFIG, relativeLogDir) | | 313 | + props.setProperty(ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG, relativeLogDir) | | 314 | + | | 315 | + val ctx = new RegistrationTestContext(props) | | 316 | + val logDirIdsByAbsolutePath = util.Map.of(new File(relativeLogDir).getAbsolutePath, logDirId) | | 317 | + manager = new BrokerLifecycleManager(ctx.config, ctx.time, "relative-cordoned-dirs-sent-in-heartbeat-", | | 318 | + logDirIdsByAbsolutePath, () => {}, () => true) | | 319 | + val controllerNode = new Node(3000, "localhost", 8021) | | 320 | + ctx.controllerNodeProvider.node.set(controllerNode) | | 321 | + | | 322 | + val registration = prepareResponse(ctx, new BrokerRegistrationResponse(new BrokerRegistrationResponseData().setBrokerEpoch(1000))) | | 323 | + manager.start(() => ctx.highestMetadataOffset.get(), | | 324 | + ctx.mockChannelManager, ctx.clusterId, ctx.advertisedListeners, | | 325 | + Collections.emptyMap(), OptionalLong.empty()) | | 326 | + poll(ctx, manager, registration) | | 327 | + | | 328 | + // This request is created before the response indicating catch-up is processed. | | 329 | + val beforeCatchUp = poll(ctx, manager, prepareResponse[BrokerHeartbeatRequest](ctx, | | 330 | + new BrokerHeartbeatResponse(new BrokerHeartbeatResponseData().setIsCaughtUp(true)))) | | 331 | + assertNull(beforeCatchUp.data().cordonedLogDirs()) | | 332 | + | | 333 | + // The next request reflects the broker having processed the catch-up response. | | 334 | + val afterCatchUp = poll(ctx, manager, prepareResponse[BrokerHeartbeatRequest](ctx, | | 335 | + new BrokerHeartbeatResponse(new BrokerHeartbeatResponseData()))) | | 336 | + assertEquals(Set(logDirId), afterCatchUp.data().cordonedLogDirs().asScala.toSet) | | 337 | + } | | 338 | + | 306 | 339 | @Test | 307 | 340 | def testCordonedLogDirs(): Unit = { | 308 | 341 | val ctx = new RegistrationTestContext(configProperties) | |
Collapse file Copy file name to clipboardExpand all lines: core/src/test/scala/unit/kafka/server/DynamicBrokerConfigTest.scala +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,6 +47,7 @@ import org.mockito.ArgumentMatchers.{anySet, anyString} | 47 | 47 | import org.mockito.Mockito._ | 48 | 48 | import org.mockito.{ArgumentCaptor, ArgumentMatchers, Mockito} | 49 | 49 |
| | 50 | +import java.io.File | 50 | 51 | import java.util.concurrent.atomic.AtomicReference | 51 | 52 | import java.util.concurrent.{CompletionStage, TimeUnit} | 52 | 53 | import java.util.{Optional, Properties, Map => JMap} | @@ -1230,6 +1231,32 @@ class DynamicBrokerConfigTest { | 1230 | 1231 | verify(ctx.directoryEventHandler, times(4)).handleCordoned(anySet) | 1231 | 1232 | } | 1232 | 1233 |
| | 1234 | + @Test | | 1235 | + def testDynamicLogConfigRelativeCordonedLogDir(): Unit = { | | 1236 | + // createBrokerConfig uses a mix of relative and absolute log dirs when logDirCount is greater than one. | | 1237 | + val origProps = TestUtils.createBrokerConfig(0, logDirCount = 2) | | 1238 | + val ctx = new DynamicLogConfigContext(origProps) | | 1239 | + val relativeLogDir = ctx.config.logDirs().asScala.find(dir => !new File(dir).isAbsolute).get | | 1240 | + val absoluteLogDir = new File(relativeLogDir).getAbsolutePath | | 1241 | + val directoryId = Uuid.randomUuid() | | 1242 | + // Only the absolute path resolves to an ID, matching how LogManager keys its directory ID map. | | 1243 | + Mockito.when(ctx.logManagerMock.directoryId(ArgumentMatchers.anyString())).thenAnswer(invocation => | | 1244 | + if (absoluteLogDir == invocation.getArgument[String](0)) Optional.of(directoryId) else Optional.empty()) | | 1245 | + | | 1246 | + val props = new Properties() | | 1247 | + props.put(ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG, relativeLogDir) | | 1248 | + ctx.config.dynamicConfig.updateBrokerConfig(0, props) | | 1249 | + assertEquals(util.List.of(relativeLogDir), ctx.config.cordonedLogDirs) | | 1250 | + verify(ctx.logManagerMock).updateCordonedLogDirs(util.Set.of(absoluteLogDir)) | | 1251 | + verify(ctx.directoryEventHandler).handleCordoned(util.Set.of(directoryId)) | | 1252 | + | | 1253 | + props.put(ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG, absoluteLogDir) | | 1254 | + ctx.config.dynamicConfig.updateBrokerConfig(0, props) | | 1255 | + assertEquals(util.List.of(absoluteLogDir), ctx.config.cordonedLogDirs) | | 1256 | + verify(ctx.logManagerMock, times(2)).updateCordonedLogDirs(util.Set.of(absoluteLogDir)) | | 1257 | + verify(ctx.directoryEventHandler, times(2)).handleCordoned(util.Set.of(directoryId)) | | 1258 | + } | | 1259 | + | 1233 | 1260 | @Test | 1234 | 1261 | def testLogRetentionTimeMinutesIsNotDynamicallyReconfigurable(): Unit = { | 1235 | 1262 | val origProps = TestUtils.createBrokerConfig(0, port = 8181) | |
Collapse file Copy file name to clipboardExpand all lines: core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 |
| 18 | 18 | package kafka.server | 19 | 19 |
| | 20 | +import java.io.File | 20 | 21 | import java.net.InetSocketAddress | 21 | 22 | import java.nio.file.Files | 22 | 23 | import java.util | @@ -1722,6 +1723,32 @@ class KafkaConfigTest { | 1722 | 1723 | assertEquals(util.List.of(dataDir1, dataDir2), config.logDirs) | 1723 | 1724 | } | 1724 | 1725 |
| | 1726 | + @Test | | 1727 | + def testRelativeLogDirWithRelativeOrAbsoluteCordon(): Unit = { | | 1728 | + val relativeLogDir = "relative/path/to/data/dir" | | 1729 | + | | 1730 | + val props = new Properties() | | 1731 | + props.setProperty(KRaftConfigs.PROCESS_ROLES_CONFIG, "broker") | | 1732 | + props.setProperty(KRaftConfigs.CONTROLLER_LISTENER_NAMES_CONFIG, "SSL") | | 1733 | + props.setProperty(ServerLogConfigs.LOG_DIR_CONFIG, relativeLogDir) | | 1734 | + props.setProperty(ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG, relativeLogDir) | | 1735 | + props.setProperty(KRaftConfigs.NODE_ID_CONFIG, "1") | | 1736 | + props.setProperty(QuorumConfig.QUORUM_VOTERS_CONFIG, "2@localhost:9093") | | 1737 | + | | 1738 | + val config = KafkaConfig.fromProps(props) | | 1739 | + val absoluteLogDir = new File(relativeLogDir).getAbsolutePath | | 1740 | + assertEquals(util.List.of(relativeLogDir), config.logDirs()) | | 1741 | + assertEquals(util.List.of(absoluteLogDir), config.absoluteLogDirs()) | | 1742 | + assertEquals(util.List.of(relativeLogDir), config.cordonedLogDirs()) | | 1743 | + assertEquals(util.List.of(absoluteLogDir), config.absoluteCordonedLogDirs()) | | 1744 | + | | 1745 | + props.setProperty(ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG, absoluteLogDir) | | 1746 | + val configWithAbsoluteCordon = KafkaConfig.fromProps(props) | | 1747 | + assertEquals(util.List.of(relativeLogDir), configWithAbsoluteCordon.logDirs()) | | 1748 | + assertEquals(util.List.of(absoluteLogDir), configWithAbsoluteCordon.cordonedLogDirs()) | | 1749 | + assertEquals(util.List.of(absoluteLogDir), configWithAbsoluteCordon.absoluteCordonedLogDirs()) | | 1750 | + } | | 1751 | + | 1725 | 1752 | @Test | 1726 | 1753 | def testCordonAllLogDirs(): Unit = { | 1727 | 1754 | val dataDir1 = "/path/to/data/dir/1" | |
Collapse file Copy file name to clipboardExpand all lines: server-common/src/main/java/org/apache/kafka/server/config/ServerLogConfigs.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,7 +53,7 @@ public class ServerLogConfigs { | 53 | 53 |
| 54 | 54 | public static final String CORDONED_LOG_DIRS_CONFIG = "cordoned.log.dirs"; | 55 | 55 | public static final List<String> CORDONED_LOG_DIRS_DEFAULT = List.of(); | 56 | | - public static final String CORDONED_LOG_DIRS_DOC = "A comma-separated list of the directories that are cordoned. Entries in this list must be entries in log.dirs or log.dir configuration. This can also be set to * to cordon all log directories."; | | 56 | + public static final String CORDONED_LOG_DIRS_DOC = "A comma-separated list of the directories that are cordoned. Entries in this list must match log.dirs or log.dir entries by absolute path. This can also be set to * to cordon all log directories."; | 57 | 57 | public static final String CORDONED_LOG_DIRS_ALL = "*"; | 58 | 58 |
| 59 | 59 | public static final String LOG_SEGMENT_BYTES_CONFIG = ServerTopicConfigSynonyms.serverSynonym(TopicConfig.SEGMENT_BYTES_CONFIG); | |
Collapse file Copy file name to clipboardExpand all lines: server/src/main/java/org/apache/kafka/server/BrokerLifecycleManager.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -651,7 +651,7 @@ public void run() { | 651 | 651 | // Now that the broker has caught up with the latest metadata, the configuration should | 652 | 652 | // be up to date, so we can retrieve the cordoned log dirs to include them in the | 653 | 653 | // next heartbeat request | 654 | | - cordonedLogDirs = config.cordonedLogDirs().stream() | | 654 | + cordonedLogDirs = config.absoluteCordonedLogDirs().stream() | 655 | 655 | .flatMap(logDir -> Optional.ofNullable(logDirs.get(logDir)).stream()) | 656 | 656 | .collect(Collectors.toSet()); | 657 | 657 | } else { | |
Collapse file Copy file name to clipboardExpand all lines: server/src/main/java/org/apache/kafka/server/config/AbstractKafkaConfig.java +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 54 | 54 | import org.slf4j.Logger; | 55 | 55 | import org.slf4j.LoggerFactory; | 56 | 56 |
| | 57 | +import java.io.File; | 57 | 58 | import java.util.Collections; | 58 | 59 | import java.util.HashMap; | 59 | 60 | import java.util.HashSet; | @@ -154,6 +155,10 @@ public List<String> logDirs() { | 154 | 155 | return Optional.ofNullable(getList(ServerLogConfigs.LOG_DIRS_CONFIG)).orElse(getList(ServerLogConfigs.LOG_DIR_CONFIG)); | 155 | 156 | } | 156 | 157 |
| | 158 | + public List<String> absoluteLogDirs() { | | 159 | + return toAbsolutePaths(logDirs()); | | 160 | + } | | 161 | + | 157 | 162 | public List<String> cordonedLogDirs() { | 158 | 163 | List<String> configuredCordonedLogDirs = getList(ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG); | 159 | 164 | if (configuredCordonedLogDirs.contains(ServerLogConfigs.CORDONED_LOG_DIRS_ALL)) { | @@ -162,6 +167,16 @@ public List<String> cordonedLogDirs() { | 162 | 167 | return configuredCordonedLogDirs; | 163 | 168 | } | 164 | 169 |
| | 170 | + public List<String> absoluteCordonedLogDirs() { | | 171 | + return toAbsolutePaths(cordonedLogDirs()); | | 172 | + } | | 173 | + | | 174 | + private static List<String> toAbsolutePaths(List<String> paths) { | | 175 | + return paths.stream() | | 176 | + .map(path -> new File(path).getAbsolutePath()) | | 177 | + .toList(); | | 178 | + } | | 179 | + | 165 | 180 | public int numIoThreads() { | 166 | 181 | return getInt(ServerConfigs.NUM_IO_THREADS_CONFIG); | 167 | 182 | } | |
Collapse file Copy file name to clipboardExpand all lines: server/src/main/java/org/apache/kafka/server/config/DynamicLogConfig.java +13-9Lines changed: 13 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | import org.apache.kafka.storage.internals.log.LogConfig; | 23 | 23 | import org.apache.kafka.storage.internals.log.LogManager; | 24 | 24 |
| | 25 | +import java.io.File; | 25 | 26 | import java.util.Collection; | 26 | 27 | import java.util.HashMap; | 27 | 28 | import java.util.List; | @@ -123,13 +124,16 @@ private void validateLogRemoteCopyLagBytes(AbstractKafkaConfig newConfig) { | 123 | 124 | } | 124 | 125 |
| 125 | 126 | private void validateCordonedLogDirs(AbstractKafkaConfig newConfig) { | 126 | | - List<String> logDirs = newConfig.logDirs(); | | 127 | + List<String> absoluteLogDirs = newConfig.absoluteLogDirs(); | 127 | 128 | List<String> cordonedLogDirs = newConfig.cordonedLogDirs(); | 128 | | - cordonedLogDirs.forEach(dir -> { | 129 | | - if (!logDirs.contains(dir)) { | | 129 | + cordonedLogDirs.forEach(cordonedLogDir -> { | | 130 | + String absoluteCordonedLogDir = new File(cordonedLogDir).getAbsolutePath(); | | 131 | + if (!absoluteLogDirs.contains(absoluteCordonedLogDir)) { | | 132 | + String invalidLogDir = cordonedLogDir.equals(absoluteCordonedLogDir) | | 133 | + ? cordonedLogDir : cordonedLogDir + " (absolute path: " + absoluteCordonedLogDir + ")"; | 130 | 134 | throw new ConfigException(ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG, cordonedLogDirs, | 131 | | - "Invalid entry in " + ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG + ": " + dir + ". " + | 132 | | - "All cordoned log dirs must be entries of " + ServerLogConfigs.LOG_DIRS_CONFIG + " or " + ServerLogConfigs.LOG_DIR_CONFIG + "."); | | 135 | + "Invalid entry in " + ServerLogConfigs.CORDONED_LOG_DIRS_CONFIG + ": " + invalidLogDir + ". " + | | 136 | + "All cordoned log dirs must match " + ServerLogConfigs.LOG_DIRS_CONFIG + " or " + ServerLogConfigs.LOG_DIR_CONFIG + " entries by absolute path."); | 133 | 137 | } | 134 | 138 | }); | 135 | 139 | } | @@ -154,10 +158,10 @@ public void reconfigure(AbstractKafkaConfig oldConfig, AbstractKafkaConfig newCo | 154 | 158 | logManager.reconfigureDefaultLogConfig(new LogConfig(newBrokerDefaults)); | 155 | 159 | updateLogsConfig(newBrokerDefaults); | 156 | 160 |
| 157 | | - List<String> cordonedLogDirs = newConfig.cordonedLogDirs(); | 158 | | - logManager.updateCordonedLogDirs(Set.copyOf(cordonedLogDirs)); | 159 | | - directoryEventHandler.handleCordoned(cordonedLogDirs.stream() | 160 | | - .flatMap(dir -> logManager.directoryId(dir).stream()) | | 161 | + List<String> absoluteCordonedLogDirs = newConfig.absoluteCordonedLogDirs(); | | 162 | + logManager.updateCordonedLogDirs(Set.copyOf(absoluteCordonedLogDirs)); | | 163 | + directoryEventHandler.handleCordoned(absoluteCordonedLogDirs.stream() | | 164 | + .flatMap(absoluteCordonedLogDir -> logManager.directoryId(absoluteCordonedLogDir).stream()) | 161 | 165 | .collect(Collectors.toUnmodifiableSet())); | 162 | 166 | } | 163 | 167 | } |
Collapse file Copy file name to clipboardExpand all lines: server/src/test/java/org/apache/kafka/server/CordonedLogDirsIntegrationTest.java +47Lines changed: 47 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 32 | 32 | import org.apache.kafka.clients.admin.UpdateFeaturesResult; | 33 | 33 | import org.apache.kafka.common.TopicPartition; | 34 | 34 | import org.apache.kafka.common.TopicPartitionReplica; | | 35 | +import org.apache.kafka.common.Uuid; | 35 | 36 | import org.apache.kafka.common.config.ConfigResource; | 36 | 37 | import org.apache.kafka.common.errors.InvalidConfigurationException; | 37 | 38 | import org.apache.kafka.common.errors.InvalidReplicaAssignmentException; | | 42 | 43 | import org.apache.kafka.common.test.api.ClusterTest; | 43 | 44 | import org.apache.kafka.common.test.api.ClusterTestDefaults; | 44 | 45 | import org.apache.kafka.common.test.api.Type; | | 46 | +import org.apache.kafka.metadata.KRaftMetadataCache; | 45 | 47 | import org.apache.kafka.server.common.MetadataVersion; | 46 | 48 | import org.apache.kafka.test.TestUtils; | 47 | 49 |
| 48 | 50 | import org.junit.jupiter.api.BeforeEach; | 49 | 51 |
| | 52 | +import java.io.File; | | 53 | +import java.nio.file.Path; | 50 | 54 | import java.util.Collection; | 51 | 55 | import java.util.HashMap; | 52 | 56 | import java.util.HashSet; | @@ -201,6 +205,49 @@ public void testCordonUncordonLogDirs() throws Exception { | 201 | 205 | } | 202 | 206 | } | 203 | 207 |
| | 208 | + @ClusterTest(types = Type.KRAFT) | | 209 | + public void testCordonRelativeLogDir() throws Exception { | | 210 | + int brokerId = 0; | | 211 | + List<String> initialLogDirs = clusterInstance.brokers().get(brokerId).config().logDirs(); | | 212 | + String metadataLogDir = clusterInstance.brokers().get(brokerId).config().metadataLogDir(); | | 213 | + Path workingDirectory = Path.of("").toAbsolutePath(); | | 214 | + String relativeLogDir = initialLogDirs.stream() | | 215 | + .filter(logDir -> !logDir.equals(metadataLogDir)) | | 216 | + .map(logDir -> workingDirectory.relativize(Path.of(logDir).toAbsolutePath()).toString()) | | 217 | + .findFirst() | | 218 | + .orElseThrow(); | | 219 | + assertFalse(Path.of(relativeLogDir).isAbsolute()); | | 220 | + | | 221 | + clusterInstance.restartBroker(brokerId, Map.of(LOG_DIRS_CONFIG, relativeLogDir)); | | 222 | + clusterInstance.waitForReadyBrokers(); | | 223 | + assertEquals(List.of(relativeLogDir), clusterInstance.brokers().get(brokerId).config().logDirs()); | | 224 | + | | 225 | + String absoluteLogDir = new File(relativeLogDir).getAbsolutePath(); | | 226 | + Set<Uuid> expectedDirectoryIds = Set.copyOf(clusterInstance.brokers().get(brokerId).logManager().directoryIds().values()); | | 227 | + | | 228 | + try (Admin admin = clusterInstance.admin()) { | | 229 | + setCordonedLogDirs(admin, List.of(relativeLogDir), BROKER_0); | | 230 | + | | 231 | + // Wait until the broker marks the resolved absolute log directory as cordoned. | | 232 | + TestUtils.waitForCondition(() -> { | | 233 | + Map<String, LogDirDescription> descriptions = admin.describeLogDirs(List.of(brokerId)).allDescriptions().get().get(brokerId); | | 234 | + return descriptions.containsKey(absoluteLogDir) && descriptions.get(absoluteLogDir).isCordoned(); | | 235 | + }, 10_000, "Relative log directories were not marked as cordoned by the broker"); | | 236 | + | | 237 | + // Wait until controller metadata reflects the broker's cordoned directory IDs. | | 238 | + TestUtils.waitForCondition(() -> { | | 239 | + KRaftMetadataCache metadataCache = (KRaftMetadataCache) clusterInstance.brokers().get(brokerId).metadataCache(); | | 240 | + var registration = metadataCache.getImage().cluster().broker(brokerId); | | 241 | + return registration != null | | 242 | + && registration.cordonedDirectories() != null | | 243 | + && expectedDirectoryIds.equals(Set.copyOf(registration.cordonedDirectories())); | | 244 | + }, 10_000, "Relative cordoned log directories were not propagated to the controller"); | | 245 | + | | 246 | + Throwable exception = assertThrows(ExecutionException.class, () -> admin.createTopics(newTopic(TOPIC1, (short) 1)).all().get()); | | 247 | + assertInstanceOf(InvalidReplicationFactorException.class, exception.getCause()); | | 248 | + } | | 249 | + } | | 250 | + | 204 | 251 | @ClusterTest( | 205 | 252 | serverProperties = { | 206 | 253 | @ClusterConfigProperty(key = CORDONED_LOG_DIRS_CONFIG, value = "*") | |
|