Skip to content

Commit 4cdd4b6

Browse files
authored
KAFKA-19071: Fix doc for remote.storage.enable (#19345)
As of 3.9, Kafka allows disabling remote storage on a topic after it was enabled. It allows subsequent enabling and disabling too. However the documentation says otherwise and needs to be corrected. Doc: https://kafka.apache.org/39/documentation/#topicconfigs_remote.storage.enable Reviewers: Luke Chen <[email protected]>, PoAn Yang <[email protected]>, Ken Huang <[email protected]>
1 parent c8fe551 commit 4cdd4b6

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

clients/src/main/java/org/apache/kafka/common/config/TopicConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ public class TopicConfig {
8080
"Moreover, it triggers the rolling of new segment if the retention.ms condition is satisfied.";
8181

8282
public static final String REMOTE_LOG_STORAGE_ENABLE_CONFIG = "remote.storage.enable";
83-
public static final String REMOTE_LOG_STORAGE_ENABLE_DOC = "To enable tiered storage for a topic, set this configuration as true. " +
84-
"You can not disable this config once it is enabled. It will be provided in future versions.";
83+
public static final String REMOTE_LOG_STORAGE_ENABLE_DOC = "To enable tiered storage for a topic, set this configuration to true. " +
84+
"To disable tiered storage for a topic that has it enabled, set this configuration to false. " +
85+
"When disabling, you must also set <code>remote.log.delete.on.disable</code> to true.";
8586

8687
public static final String LOCAL_LOG_RETENTION_MS_CONFIG = "local.retention.ms";
8788
public static final String LOCAL_LOG_RETENTION_MS_DOC = "The number of milliseconds to keep the local log segment before it gets deleted. " +

core/src/test/scala/integration/kafka/admin/RemoteTopicCrudTest.scala

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,36 @@ class RemoteTopicCrudTest extends IntegrationTestHarness {
441441
AlterConfigOp.OpType.SET),
442442
))
443443
assertThrowsException(classOf[InvalidConfigurationException],
444-
() => admin.incrementalAlterConfigs(configs).all().get(), "Disabling remote storage feature on the topic level is not supported.")
444+
() => admin.incrementalAlterConfigs(configs).all().get(), "It is invalid to disable remote storage without deleting remote data. " +
445+
"If you want to keep the remote data and turn to read only, please set `remote.storage.enable=true,remote.log.copy.disable=true`. " +
446+
"If you want to disable remote storage and delete all remote data, please set `remote.storage.enable=false,remote.log.delete.on.disable=true`.")
447+
}
448+
449+
@ParameterizedTest
450+
@ValueSource(strings = Array("kraft"))
451+
def testUpdateTopicConfigWithDisablingRemoteStorageWithDeleteOnDisable(quorum: String): Unit = {
452+
val admin = createAdminClient()
453+
val topicConfig = new Properties
454+
topicConfig.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true")
455+
TestUtils.createTopicWithAdmin(admin, testTopicName, brokers, controllerServers, numPartitions, numReplicationFactor,
456+
topicConfig = topicConfig)
457+
458+
val configs = new util.HashMap[ConfigResource, util.Collection[AlterConfigOp]]()
459+
configs.put(new ConfigResource(ConfigResource.Type.TOPIC, testTopicName),
460+
util.Arrays.asList(
461+
new AlterConfigOp(new ConfigEntry(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "false"),
462+
AlterConfigOp.OpType.SET),
463+
new AlterConfigOp(new ConfigEntry(TopicConfig.REMOTE_LOG_DELETE_ON_DISABLE_CONFIG, "true"),
464+
AlterConfigOp.OpType.SET)
465+
))
466+
admin.incrementalAlterConfigs(configs).all().get()
467+
468+
val newProps = new Properties()
469+
configs.get(new ConfigResource(ConfigResource.Type.TOPIC, testTopicName)).forEach { op =>
470+
newProps.setProperty(op.configEntry().name(), op.configEntry().value())
471+
}
472+
473+
verifyRemoteLogTopicConfigs(newProps)
445474
}
446475

447476
@ParameterizedTest

0 commit comments

Comments
 (0)