You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "clolov (via GitHub)" <gi...@apache.org> on 2023/08/07 17:02:36 UTC

[GitHub] [kafka] clolov opened a new pull request, #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

clolov opened a new pull request, #14161:
URL: https://github.com/apache/kafka/pull/14161

   # TODO
   I need to find where the unit/integration tests for this behaviour are in order to add the manual test to them
   
   ### Summary
   
   The purpose of this change is to not allow a broker to start up with Tiered Storage disabled (`remote.log.storage.system.enable=false`) while there are still topics which have `remote.storage.enable` set.
   
   ### Testing
   ```
   [2023-08-07 18:01:30,654] ERROR Exiting Kafka due to fatal exception during startup. (kafka.Kafka$)
   org.apache.kafka.common.config.ConfigException: You have to delete all topics with the property remote.storage.enable (i.e. mrfreeze) before disabling tiered storage cluster-wide
   	at kafka.server.TopicConfigHandler.processConfigChanges(ConfigHandler.scala:71)
   	at kafka.server.ZkConfigManager.$anonfun$startup$4(ZkConfigManager.scala:175)
   	at kafka.server.ZkConfigManager.$anonfun$startup$4$adapted(ZkConfigManager.scala:174)
   	at scala.collection.immutable.Map$Map4.foreach(Map.scala:569)
   	at kafka.server.ZkConfigManager.$anonfun$startup$1(ZkConfigManager.scala:174)
   	at kafka.server.ZkConfigManager.$anonfun$startup$1$adapted(ZkConfigManager.scala:165)
   	at scala.collection.immutable.HashMap.foreach(HashMap.scala:1115)
   	at kafka.server.ZkConfigManager.startup(ZkConfigManager.scala:165)
   	at kafka.server.KafkaServer.startup(KafkaServer.scala:571)
   	at kafka.Kafka$.main(Kafka.scala:113)
   	at kafka.Kafka.main(Kafka.scala)
   ```


-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1308983492


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -871,12 +871,17 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    // We would like to validate the configuration no matter whether the logs have materialised on disk or not.
+    // Otherwise we risk someone creating a tiered-topic, disabling Tiered Storage cluster-wide and the check
+    // failing since the logs for the topic are non-existent.
+    LogConfig.validateRemoteStorageOnlyIfSystemEnabled(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)

Review Comment:
   I think this doesn't work in this situation since the method I am calling is from a Java class



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1304596807


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -21,8 +21,8 @@ import kafka.utils.TestUtils
 import org.apache.kafka.common.security.JaasUtils
 import org.junit.jupiter.api.Assertions.{assertEquals, assertNull, assertThrows, fail}
 import org.junit.jupiter.api.Test
-import java.util.Properties
 
+import java.util.Properties

Review Comment:
   nit: this file change can be reverted



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1308425188


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -871,12 +871,17 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    // We would like to validate the configuration no matter whether the logs have materialised on disk or not.
+    // Otherwise we risk someone creating a tiered-topic, disabling Tiered Storage cluster-wide and the check
+    // failing since the logs for the topic are non-existent.
+    LogConfig.validateRemoteStorageOnlyIfSystemEnabled(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)

Review Comment:
   nit
   
   it's beneficial to have named arguments for readibility. See: 
   
   > Use named arguments when passing in literal values if the meaning is at all unclear, for example instead of Utils.delete(true) prefer Utils.delete(recursive=true).
   
   from https://kafka.apache.org/coding-guide



##########
core/src/test/scala/integration/kafka/admin/RemoteTopicCrudTest.scala:
##########
@@ -301,6 +300,43 @@ class RemoteTopicCrudTest extends IntegrationTestHarness {
     //      "Remote log segments should be deleted only once by the leader")
   }
 
+  @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
+  @ValueSource(strings = Array("zk", "kraft"))
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(quorum: String): Unit = {
+    val topicConfig = new Properties()
+    topicConfig.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true")
+
+    TestUtils.createTopicWithAdmin(createAdminClient(), testTopicName, brokers, numPartitions, brokerCount,
+      topicConfig = topicConfig)
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnectOrNull).head
+    instanceConfigs = List(KafkaConfig.fromProps(tsDisabledProps))
+
+    if (quorum.equals("zk")) {

Review Comment:
   nit
   
   You can also use `isKRaftTest()` here and move Zk scenario to else.



-- 
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] satishd commented on pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on PR #14161:
URL: https://github.com/apache/kafka/pull/14161#issuecomment-1698298310

   Merging to trunk as the test failures are not related to this change.


-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1288939068


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   @clolov could you please check if we call some form of LogConfig.validate() on startup? (I think we do when we create LogManager). In which case you may want to bring the broker level config to LogConfig like this: https://github.com/apache/kafka/pull/14176 and add you new validation in LogManager.validate() similar to how we are validating in other PR.



-- 
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] satishd commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1289928040


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG) != null) {

Review Comment:
   Why are we checking only for the existence of the property instead of checking whether that property is set as true? This requires more validation checks whenever this config value is set as true but it gives better flexibility to users. 
   
   Is it to keep the remote storage related configs at topic level separation better?



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1304576992


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -870,12 +870,17 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    // We would like to validate the configuration no matter whether the logs have materialised on disk or not.
+    // Otherwise we risk someone creating a tiered-topic, disabling Tiered Storage cluster-wide and the check
+    // failing since the logs for the topic are non-existent.
+    LogConfig.validateRemoteStorageOnlyIfSystemEnabled(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)

Review Comment:
   Mmm, I would prefer we don't. Otherwise one can end up in a situation where they have topics with remote.storage.enable=true and tiered storage cluster-wide disabled.



-- 
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] showuon commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1302442110


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -870,12 +870,14 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    LogConfig.validateTopicLogConfigValues(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)
     if (logs.nonEmpty) {
-      // Combine the default properties with the overrides in zk to create the new LogConfig

Review Comment:
   Fair enough. Could you add some comments about it? Thanks.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1297412799


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   ~~I have been looking at this a bit more and I don't think the current codebase invokes the validation path on pulling dynamic configurations. In other words, I believe there is client to broker validation, broker to metadata store validation, but once the data makes it in the metadata store we no longer carry out validation when we read it back from there. Unless I am wrong this means that we cannot unite these two approaches without big changes (system-wide needs to happen when we pull the dynamic configuration while the topic-specific needs to happen at broker to metadata store boundary). Am I wrong?~~
   I believe I figured out how to combine them and will have a new commit tomorrow morning



-- 
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] clolov commented on pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on PR #14161:
URL: https://github.com/apache/kafka/pull/14161#issuecomment-1669704586

   Politely requesting a review @showuon @divijvaidya @satishd!


-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1300091311


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,

Review Comment:
   If we are planning to validate only the case where tiered storage functionality is enabled (or) disabled in the broker during restarts. Can we use the `validateRemoteStorageOnlyIfSystemEnabled` instead of `validateTopicLogConfigValues`?



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,
+                                                    boolean isRemoteLogStorageSystemEnabled,
+                                                    boolean isReceivingConfigFromStore) {
         validateValues(props);
         boolean isRemoteLogStorageEnabled = (Boolean) props.get(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG);
         if (isRemoteLogStorageEnabled) {
-            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled);
-            validateNoRemoteStorageForCompactedTopic(props);
-            validateRemoteStorageRetentionSize(props);
-            validateRemoteStorageRetentionTime(props);
+            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled, isReceivingConfigFromStore);
+            if (!isReceivingConfigFromStore) {
+                validateNoRemoteStorageForCompactedTopic(props);
+                validateRemoteStorageRetentionSize(props);
+                validateRemoteStorageRetentionTime(props);
+            }
         }
     }
 
-    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled) {
+    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled, boolean isReceivingConfigFromStore) {
         if (!isRemoteLogStorageSystemEnabled) {
-            throw new ConfigException("Tiered Storage functionality is disabled in the broker. " +
-                    "Topic cannot be configured with remote log storage.");
+            if (isReceivingConfigFromStore) {

Review Comment:
   Can we update the message such that it's same for both the cases?
   
   If the user disables the tiered storage functionality in the broker and restarts the node, and if any topic is left with remote storage enabled, then the same error message can be reused.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1301856757


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,27 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,

Review Comment:
   Yup, will do



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1298593281


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,96 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head

Review Comment:
   This will take a bit of time because I am still searching whether we have tests which allow easy reconfiguration of broker properties + bounce in the rest of the codebase. I have pushed my latest commits for a review in the meantime.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1286890333


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   If you are referring to the `emote.log.storage.system.enable` property it is a read-only property and is only stored in server.properties (i.e. not in Zookeeper).



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1304548979


##########
core/src/test/scala/integration/kafka/admin/RemoteTopicCrudTest.scala:
##########
@@ -301,6 +300,70 @@ class RemoteTopicCrudTest extends IntegrationTestHarness {
     //      "Remote log segments should be deleted only once by the leader")
   }
 
+  @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
+  @ValueSource(strings = Array("zk"))
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopicZK(quorum: String): Unit = {
+    val topicConfig = new Properties()
+    topicConfig.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true")
+
+    TestUtils.createTopicWithAdmin(createAdminClient(), testTopicName, brokers, numPartitions, brokerCount,
+      topicConfig = topicConfig)
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnectOrNull).head
+    instanceConfigs = List(KafkaConfig.fromProps(tsDisabledProps))
+
+    assertThrows(classOf[ConfigException], () => recreateBrokers(startup = true))
+  }

Review Comment:
   ```suggestion
     @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
     @ValueSource(strings = Array("zk", "kraft"))
     def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(quorum: String): Unit = {
       val topicConfig = new Properties()
       topicConfig.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true")
   
       TestUtils.createTopicWithAdmin(createAdminClient(), testTopicName, brokers, numPartitions, brokerCount,
         topicConfig = topicConfig)
   
       val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnectOrNull).head
       instanceConfigs = List(KafkaConfig.fromProps(tsDisabledProps))
   
       if (quorum.equals("zk")) {
         assertThrows(classOf[ConfigException], () => recreateBrokers(startup = true))
       } else {
         recreateBrokers(startup = true)
         assertTrue(faultHandler.firstException().getCause.isInstanceOf[ConfigException])
         // Normally the exception is thrown as part of the TearDown method of the parent class(es). We would like to not do this.
         faultHandler.setIgnore(true)
       }
     }
   ```
   
   With this, we can have a common test for both the modes.



##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -870,12 +870,17 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    // We would like to validate the configuration no matter whether the logs have materialised on disk or not.
+    // Otherwise we risk someone creating a tiered-topic, disabling Tiered Storage cluster-wide and the check
+    // failing since the logs for the topic are non-existent.
+    LogConfig.validateRemoteStorageOnlyIfSystemEnabled(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)

Review Comment:
   Can we allow the tiered storage functionality disablement since no data is in remote?



##########
core/src/test/scala/integration/kafka/admin/RemoteTopicCrudTest.scala:
##########
@@ -301,6 +300,70 @@ class RemoteTopicCrudTest extends IntegrationTestHarness {
     //      "Remote log segments should be deleted only once by the leader")
   }
 
+  @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
+  @ValueSource(strings = Array("zk"))
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopicZK(quorum: String): Unit = {
+    val topicConfig = new Properties()
+    topicConfig.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, "true")
+
+    TestUtils.createTopicWithAdmin(createAdminClient(), testTopicName, brokers, numPartitions, brokerCount,
+      topicConfig = topicConfig)
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnectOrNull).head
+    instanceConfigs = List(KafkaConfig.fromProps(tsDisabledProps))
+
+    assertThrows(classOf[ConfigException], () => recreateBrokers(startup = true))
+  }
+
+  @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
+  @ValueSource(strings = Array("zk"))
+  def testClusterWithoutTieredStorageStartsSuccessfullyIfTopicWithTieringDisabledZK(quorum: String): Unit = {

Review Comment:
   ```suggestion
     @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
     @ValueSource(strings = Array("zk", "kraft"))
     def testClusterWithoutTieredStorageStartsSuccessfullyIfTopicWithTieringDisabled(quorum: String): Unit = {
   ```
   With this, we can have a common test for both the modes.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1304576992


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -870,12 +870,17 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    // We would like to validate the configuration no matter whether the logs have materialised on disk or not.
+    // Otherwise we risk someone creating a tiered-topic, disabling Tiered Storage cluster-wide and the check
+    // failing since the logs for the topic are non-existent.
+    LogConfig.validateRemoteStorageOnlyIfSystemEnabled(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)

Review Comment:
   Mmm, I would prefer we don't. Otherwise you will end up in a situation where you have topics with remote.storage.enable=true and tiered storage cluster-wide disabled.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1287188953


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,92 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)

Review Comment:
   I do not know why there isn't a TestUtils.createTopicConfigs ¯\\\_(ツ)\_/¯
   
   Happy to add it if others think it might be useful!



##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,92 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)

Review Comment:
   I do not know why there isn't a TestUtils.createTopicConfigs ¯\\\_(ツ)\_/¯
   
   Happy to add it if others think it might be useful!



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1286895377


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   In essence, we cannot block the configuration if the property is read-only. What we can do is terminate the startup of the broker should we detect that this property is set to false and there are topics with a `remote.storage.enable` property set (regardless of whether it is true or false).



##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   In essence, we cannot block the configuration change if the property is read-only. What we can do is terminate the startup of the broker should we detect that this property is set to false and there are topics with a `remote.storage.enable` property set (regardless of whether it is true or false).



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1288298071


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   We are ensuring that the system level remote storage cannot be disabled when the topics are enabled with remote storage. If the user downgrades the build, then this validation won't be applicable. 



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294261443


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG) != null) {

Review Comment:
   Sure, I will change to condition to only check for the value being true rather than its presence! As mentioned, I am happy with either 😊 



##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG) != null) {

Review Comment:
   Sure, I will change to condition to only check for the value being true rather than its presence! As mentioned, I am happy with either 😊 



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294991302


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,96 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    assertThrows(classOf[ConfigException], () => TestUtils.createServer(KafkaConfig.fromProps(tsDisabledProps)))
+  }
+
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithDisabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    var server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, false.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    server = TestUtils.createServer(KafkaConfig.fromProps(tsDisabledProps))
+
+    server.shutdown()
+  }
+
+  @Test
+  def testClusterWithoutTieredStorageFailsOnStartupIfTopicWithTieringEnabled(): Unit = {
+    val serverProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(serverProps))
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()

Review Comment:
   this should be done in finally again so that if an exception is thrown, we are correctly cleaning up resources used by test i.e. closing the server.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1301784967


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,

Review Comment:
   Okay, hopefully addressed in the latest commit



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1288309828


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   > For my understanding, will this approach work if the user wants to downgrade from 3.6 to 2.8?
   
   Correct me if I am wrong here @kamalcph but downgrade is not supported in Kafka as per "Once the brokers begin using the latest protocol version, it will no longer be possible to downgrade the cluster to an older version." from https://kafka.apache.org/documentation.html#upgrade_350_zk This is true irrespective of Tiered Storage or not.
   



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1288265653


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   Sorry, can you elaborate because I am not certain I understand?



-- 
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] clolov commented on pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on PR #14161:
URL: https://github.com/apache/kafka/pull/14161#issuecomment-1697616881

   > Looks good to me. One question I have is regarding dynamically changing broker properties to disable TS. Is that possible? Is yes, then we need to add more tests here.
   > 
   > (will approve & merge once you can clarify this question please)
   
   No, as far as I have checked the code + manually tested none of the configuration in https://github.com/apache/kafka/blob/0912ca27e2a229d2ebe02f4d1dabc40ed5fab0bb/storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManagerConfig.java#L37 are dynamic


-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1300216608


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,

Review Comment:
   I am ambivalent. If I am to use `validateRemoteStorageOnlyIfSystemEnabled` I would still need another validation function to check for the topic-level config, no? Otherwise the `validateRemoteStorageOnlyIfSystemEnabled` will only operate based on knowledge of the system-wide config. Are you okay with this?



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1286889754


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   Ah, I realised that this method is also called during startup and the `kafkaConfig.remoteLogManagerConfig` is not stored in Zk since it is not a dynamic config.
   
   I was hoping we could do something like https://github.com/apache/kafka/blob/8dec3e66163420ee0c2c259eef6e0c0f3185ca17/core/src/main/scala/kafka/server/KafkaConfig.scala#L2212 . This is because we currently don't perform config validation in ConfigHandler and I was hoping there is a better place to do it.
   
   Let me think about it and will let you know if I have a better suggestion.



-- 
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] showuon commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1300875008


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,

Review Comment:
   I agree with @kamalcph  that we actually doesn't want to validate anything else except `validateRemoteStorageOnlyIfSystemEnabled`. 



##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -870,12 +870,14 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    LogConfig.validateTopicLogConfigValues(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)
     if (logs.nonEmpty) {
-      // Combine the default properties with the overrides in zk to create the new LogConfig

Review Comment:
   Why should we validate the log when the `logs` is empty?



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,
+                                                    boolean isRemoteLogStorageSystemEnabled,
+                                                    boolean isReceivingConfigFromStore) {
         validateValues(props);
         boolean isRemoteLogStorageEnabled = (Boolean) props.get(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG);
         if (isRemoteLogStorageEnabled) {
-            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled);
-            validateNoRemoteStorageForCompactedTopic(props);
-            validateRemoteStorageRetentionSize(props);
-            validateRemoteStorageRetentionTime(props);
+            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled, isReceivingConfigFromStore);
+            if (!isReceivingConfigFromStore) {
+                validateNoRemoteStorageForCompactedTopic(props);
+                validateRemoteStorageRetentionSize(props);
+                validateRemoteStorageRetentionTime(props);
+            }
         }
     }
 
-    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled) {
+    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled, boolean isReceivingConfigFromStore) {
         if (!isRemoteLogStorageSystemEnabled) {
-            throw new ConfigException("Tiered Storage functionality is disabled in the broker. " +
-                    "Topic cannot be configured with remote log storage.");
+            if (isReceivingConfigFromStore) {

Review Comment:
   I think having 2 error messages make it more clear. After all, in the restart case, the user doesn't "configure" anything but seeing this message: `Topics cannot be configured with remote log storage.` is weird.



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1286878457


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   Correct me if I am wrong here but this method is called when each broker is trying to implement the configuration change sent to it by metadata topic (kraft) or zk. Even if we reject it here, the config change will continue to persist in Zk and metadata.
   
   We need to block this configuration change at the start itself, i.e. in KafkaConfig.scala 



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1290124230


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG) != null) {

Review Comment:
   In summary, I thought it was just one more check of the kind "are you absolutely certain you have checked this and would like to proceed", but I do not feel too strongly about it if you think we should just fail if the value is set to true.



-- 
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] showuon commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294147126


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG) != null) {

Review Comment:
   I'd disagree with this. Under this change, when the users set the topic level `enable.remote.storage=false` explicitly when creating a topic. Then, when disabling system-wide `remote.log.storage.system.enable=false`, the startup will fail immediately with: 
   ```
   s"You have to delete all topics with the property remote.storage.enable (i.e. $topic) before disabling tiered storage cluster-wide"
   ```
   That doesn't make sense to me. 
   
   If you think we should notify users about this:
   ```
   Right now (and for 3.6) if I change enable.remote.storage from true to false the topic will stop being archived, but the data which is already in remote storage won't be deleted.
   ```
   I think we can add note in docs and logs when dynamically disabled topic-level `enable.remote.storage=false`, and make this check to `true` case.  WDYT?



##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   I think this is the place we can get all custom configurations in topics when startup, so this change makes sense to me.



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1300319555


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,
+                                                    boolean isRemoteLogStorageSystemEnabled,
+                                                    boolean isReceivingConfigFromStore) {
         validateValues(props);
         boolean isRemoteLogStorageEnabled = (Boolean) props.get(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG);
         if (isRemoteLogStorageEnabled) {
-            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled);
-            validateNoRemoteStorageForCompactedTopic(props);
-            validateRemoteStorageRetentionSize(props);
-            validateRemoteStorageRetentionTime(props);
+            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled, isReceivingConfigFromStore);
+            if (!isReceivingConfigFromStore) {
+                validateNoRemoteStorageForCompactedTopic(props);
+                validateRemoteStorageRetentionSize(props);
+                validateRemoteStorageRetentionTime(props);
+            }
         }
     }
 
-    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled) {
+    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled, boolean isReceivingConfigFromStore) {
         if (!isRemoteLogStorageSystemEnabled) {
-            throw new ConfigException("Tiered Storage functionality is disabled in the broker. " +
-                    "Topic cannot be configured with remote log storage.");
+            if (isReceivingConfigFromStore) {

Review Comment:
   The intention is not to supply the `boolean` to differentiate the cases. IMO, the existing error message should be sufficient:
   
   > Tiered Storage functionality is disabled in the broker. Topics cannot be configured with remote log storage.
             
   Let's wait for others opinion. cc @showuon @divijvaidya     
   
   



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1301857857


##########
core/src/test/scala/unit/kafka/server/TieredStorageSystemWideConfigTest.scala:
##########
@@ -0,0 +1,100 @@
+package unit.kafka.server
+
+import kafka.integration.KafkaServerTestHarness
+import kafka.server.KafkaConfig
+import kafka.utils.{TestInfoUtils, TestUtils}
+import org.apache.kafka.common.config.{ConfigException, TopicConfig}
+import org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig
+import org.junit.jupiter.api.Assertions.{assertThrows, assertTrue}
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.ValueSource
+
+import java.util.Properties
+
+class TieredStorageSystemWideConfigTest extends KafkaServerTestHarness {

Review Comment:
   That's a fair point, I will see whether this can be done as well



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1301852957


##########
core/src/test/scala/unit/kafka/server/TieredStorageSystemWideConfigTest.scala:
##########
@@ -0,0 +1,100 @@
+package unit.kafka.server
+
+import kafka.integration.KafkaServerTestHarness
+import kafka.server.KafkaConfig
+import kafka.utils.{TestInfoUtils, TestUtils}
+import org.apache.kafka.common.config.{ConfigException, TopicConfig}
+import org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig
+import org.junit.jupiter.api.Assertions.{assertThrows, assertTrue}
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.ValueSource
+
+import java.util.Properties
+
+class TieredStorageSystemWideConfigTest extends KafkaServerTestHarness {

Review Comment:
   Better to move the tests to RemoteTopicCrudTest.



-- 
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] satishd merged pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "satishd (via GitHub)" <gi...@apache.org>.
satishd merged PR #14161:
URL: https://github.com/apache/kafka/pull/14161


-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1296140643


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,15 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    val remoteLogStorageEnable = topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG)
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && remoteLogStorageEnable != null
+      && remoteLogStorageEnable.toBoolean) {
+      throw new ConfigException(s"You have to delete all topics with the property remote.storage.enable (i.e. $topic) before disabling tiered storage cluster-wide")

Review Comment:
   `delete` -> `disable`. 



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294263440


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   Hello @showuon and thanks for looking over the pull request! Just to confirm, you are okay with the solution proposed here i.e. to not put this validation in the LogConfig?



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1300216006


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,
+                                                    boolean isRemoteLogStorageSystemEnabled,
+                                                    boolean isReceivingConfigFromStore) {
         validateValues(props);
         boolean isRemoteLogStorageEnabled = (Boolean) props.get(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG);
         if (isRemoteLogStorageEnabled) {
-            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled);
-            validateNoRemoteStorageForCompactedTopic(props);
-            validateRemoteStorageRetentionSize(props);
-            validateRemoteStorageRetentionTime(props);
+            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled, isReceivingConfigFromStore);
+            if (!isReceivingConfigFromStore) {
+                validateNoRemoteStorageForCompactedTopic(props);
+                validateRemoteStorageRetentionSize(props);
+                validateRemoteStorageRetentionTime(props);
+            }
         }
     }
 
-    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled) {
+    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled, boolean isReceivingConfigFromStore) {
         if (!isRemoteLogStorageSystemEnabled) {
-            throw new ConfigException("Tiered Storage functionality is disabled in the broker. " +
-                    "Topic cannot be configured with remote log storage.");
+            if (isReceivingConfigFromStore) {

Review Comment:
   What would your suggestion for such a message be? I left it as two separate ones because in one situation we say "hey, you cannot disable TS on the cluster while you have TS topics" while in the other we say "hey, you cannot enable TS on topics while you do not have TS on the cluster", but I see value in your suggestion. Would you like "You cannot have topics with enabled remote storage if Tiered Storage functionality is disabled"?



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1287319821


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   For my understanding, will this approach work if the user wants to downgrade from 3.6 to 2.8?



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1287319821


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   For my understanding, will this approach will work if the user wants to downgrade from 3.6 to 2.8?



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1296143313


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,96 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    assertThrows(classOf[ConfigException], () => TestUtils.createServer(KafkaConfig.fromProps(tsDisabledProps)))
+  }
+
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithDisabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    var server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, false.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    server = TestUtils.createServer(KafkaConfig.fromProps(tsDisabledProps))
+
+    server.shutdown()
+  }
+
+  @Test
+  def testClusterWithoutTieredStorageFailsOnStartupIfTopicWithTieringEnabled(): Unit = {
+    val serverProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(serverProps))
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()
+
+    assertThrows(classOf[ConfigException], () => TestUtils.createServer(KafkaConfig.fromProps(serverProps)))
+  }
+
+  @Test
+  def testClusterWithoutTieredStorageFailsOnStartupIfTopicWithTieringDisabled(): Unit = {

Review Comment:
   Can the test name be changed? The test doesn't fail anywhere when `remote.storage.enable=false`. Could you remove the `FailsOnStartup` from test name?



##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,15 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    val remoteLogStorageEnable = topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG)
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && remoteLogStorageEnable != null
+      && remoteLogStorageEnable.toBoolean) {
+      throw new ConfigException(s"You have to delete all topics with the property remote.storage.enable (i.e. $topic) before disabling tiered storage cluster-wide")

Review Comment:
   `delete` -> `disable`.  We can hold on this till KAFKA-15290 gets reviewed.



##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,96 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    assertThrows(classOf[ConfigException], () => TestUtils.createServer(KafkaConfig.fromProps(tsDisabledProps)))
+  }
+
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithDisabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    var server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, false.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)
+
+    server.shutdown()
+
+    val tsDisabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    server = TestUtils.createServer(KafkaConfig.fromProps(tsDisabledProps))
+
+    server.shutdown()
+  }
+
+  @Test
+  def testClusterWithoutTieredStorageFailsOnStartupIfTopicWithTieringEnabled(): Unit = {
+    val serverProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(serverProps))
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)
+
+    TestUtils.createTopic(zkClient = server.zkClient, topic = "batman", servers = Seq(server), topicConfig = topicProps)

Review Comment:
   If system-level tiered storage is not enabled, then topic creation with `remote.storage.enable=true` should fail now.



##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,15 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    val remoteLogStorageEnable = topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG)
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   Instead of 
   
   `kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()` ->
   
   `kafkaConfig.isRemoteLogStorageSystemEnabled`



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1301785987


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,
+                                                    boolean isRemoteLogStorageSystemEnabled,
+                                                    boolean isReceivingConfigFromStore) {
         validateValues(props);
         boolean isRemoteLogStorageEnabled = (Boolean) props.get(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG);
         if (isRemoteLogStorageEnabled) {
-            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled);
-            validateNoRemoteStorageForCompactedTopic(props);
-            validateRemoteStorageRetentionSize(props);
-            validateRemoteStorageRetentionTime(props);
+            validateRemoteStorageOnlyIfSystemEnabled(isRemoteLogStorageSystemEnabled, isReceivingConfigFromStore);
+            if (!isReceivingConfigFromStore) {
+                validateNoRemoteStorageForCompactedTopic(props);
+                validateRemoteStorageRetentionSize(props);
+                validateRemoteStorageRetentionTime(props);
+            }
         }
     }
 
-    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled) {
+    private static void validateRemoteStorageOnlyIfSystemEnabled(boolean isRemoteLogStorageSystemEnabled, boolean isReceivingConfigFromStore) {
         if (!isRemoteLogStorageSystemEnabled) {
-            throw new ConfigException("Tiered Storage functionality is disabled in the broker. " +
-                    "Topic cannot be configured with remote log storage.");
+            if (isReceivingConfigFromStore) {

Review Comment:
   Okay, I have kept the two messages. If there are more in favour of merging them together I can do this.



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1301834895


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,27 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,

Review Comment:
   can we revert the method access specifier to `private`?



##########
core/src/test/scala/unit/kafka/server/TieredStorageSystemWideConfigTest.scala:
##########
@@ -0,0 +1,100 @@
+package unit.kafka.server
+
+import kafka.integration.KafkaServerTestHarness
+import kafka.server.KafkaConfig
+import kafka.utils.{TestInfoUtils, TestUtils}
+import org.apache.kafka.common.config.{ConfigException, TopicConfig}
+import org.apache.kafka.server.log.remote.storage.RemoteLogManagerConfig
+import org.junit.jupiter.api.Assertions.{assertThrows, assertTrue}
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.ValueSource
+
+import java.util.Properties
+
+class TieredStorageSystemWideConfigTest extends KafkaServerTestHarness {

Review Comment:
   Can we extend `IntegrationTestHarness` instead of `KafkaServerTestHarness` and unify the test-case for both the modes similar to [RemoteTopicCrudTest](https://github.com/apache/kafka/blob/trunk/core/src/test/scala/integration/kafka/admin/RemoteTopicCrudTest.scala#L77)?



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1304553332


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -870,12 +870,17 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    // We would like to validate the configuration no matter whether the logs have materialised on disk or not.
+    // Otherwise we risk someone creating a tiered-topic, disabling Tiered Storage cluster-wide and the check
+    // failing since the logs for the topic are non-existent.
+    LogConfig.validateRemoteStorageOnlyIfSystemEnabled(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)

Review Comment:
   Can we allow the tiered storage functionality disablement since no data is in remote when `logs` is empty?



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1301784533


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -870,12 +870,14 @@ class LogManager(logDirs: Seq[File],
    * Update the configuration of the provided topic.
    */
   def updateTopicConfig(topic: String,
-                        newTopicConfig: Properties): Unit = {
+                        newTopicConfig: Properties,
+                        isRemoteLogStorageSystemEnabled: Boolean): Unit = {
     topicConfigUpdated(topic)
     val logs = logsByTopic(topic)
+    // Combine the default properties with the overrides in zk to create the new LogConfig
+    val newLogConfig = LogConfig.fromProps(currentDefaultConfig.originals, newTopicConfig)
+    LogConfig.validateTopicLogConfigValues(newLogConfig.values(), isRemoteLogStorageSystemEnabled, true)
     if (logs.nonEmpty) {
-      // Combine the default properties with the overrides in zk to create the new LogConfig

Review Comment:
   I discovered this with the integration tests. I believe we should carry out the validation of the topic even if nothing has been produced yet and as such no logs have materialised. Otherwise, if someone decides to 1) create a tiered topic 2) switch off tiered storage cluster-wide this validation will merrily let it pass in its previous form.



-- 
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] divijvaidya commented on pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #14161:
URL: https://github.com/apache/kafka/pull/14161#issuecomment-1697636436

   All test failures are known flaky tests.
   ```
   [Build / JDK 8 and Scala 2.12 / kafka.api.TransactionsTest.testBumpTransactionalEpoch(String).quorum=kraft](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/kafka.api/TransactionsTest/Build___JDK_8_and_Scala_2_12___testBumpTransactionalEpoch_String__quorum_kraft/)
   [Build / JDK 8 and Scala 2.12 / kafka.server.DynamicBrokerReconfigurationTest.testThreadPoolResize()](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/kafka.server/DynamicBrokerReconfigurationTest/Build___JDK_8_and_Scala_2_12___testThreadPoolResize__/)
   [Build / JDK 8 and Scala 2.12 / org.apache.kafka.controller.QuorumControllerTest.testBalancePartitionLeaders()](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/org.apache.kafka.controller/QuorumControllerTest/Build___JDK_8_and_Scala_2_12___testBalancePartitionLeaders__/)
   [Build / JDK 8 and Scala 2.12 / org.apache.kafka.tiered.storage.integration.OffloadAndConsumeFromLeaderTest.initializationError](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/org.apache.kafka.tiered.storage.integration/OffloadAndConsumeFromLeaderTest/Build___JDK_8_and_Scala_2_12___initializationError/)
   [Build / JDK 11 and Scala 2.13 / kafka.server.DynamicBrokerReconfigurationTest.testThreadPoolResize()](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/kafka.server/DynamicBrokerReconfigurationTest/Build___JDK_11_and_Scala_2_13___testThreadPoolResize__/)
   [Build / JDK 11 and Scala 2.13 / org.apache.kafka.controller.QuorumControllerTest.testBalancePartitionLeaders()](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/org.apache.kafka.controller/QuorumControllerTest/Build___JDK_11_and_Scala_2_13___testBalancePartitionLeaders__/)
   [Build / JDK 11 and Scala 2.13 / org.apache.kafka.tiered.storage.integration.OffloadAndConsumeFromLeaderTest.initializationError](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/org.apache.kafka.tiered.storage.integration/OffloadAndConsumeFromLeaderTest/Build___JDK_11_and_Scala_2_13___initializationError/)
   [Build / JDK 11 and Scala 2.13 / org.apache.kafka.trogdor.coordinator.CoordinatorTest.testTaskRequestWithOldStartMsGetsUpdated()](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/org.apache.kafka.trogdor.coordinator/CoordinatorTest/Build___JDK_11_and_Scala_2_13___testTaskRequestWithOldStartMsGetsUpdated__/)
   [Build / JDK 17 and Scala 2.13 / kafka.server.DynamicBrokerReconfigurationTest.testThreadPoolResize()](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/kafka.server/DynamicBrokerReconfigurationTest/Build___JDK_17_and_Scala_2_13___testThreadPoolResize__/)
   [Build / JDK 17 and Scala 2.13 / org.apache.kafka.tiered.storage.integration.OffloadAndConsumeFromLeaderTest.initializationError](https://ci-builds.apache.org/job/Kafka/job/kafka-pr/job/PR-14161/12/testReport/junit/org.apache.kafka.tiered.storage.integration/OffloadAndConsumeFromLeaderTest/Build___JDK_17_and_Scala_2_13___initializationError/)
   ```
   
   Merging this in to trunk and 3.6


-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1290120601


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG) != null) {

Review Comment:
   My reasoning was the following:
   * When KIP-950 is reviewed the behaviour from chaning `enable.remote.storage=true` to `enable.remote.storage=false` will be defined and a retention/deletion policy will be in effect.
   * Right now (and for 3.6) if I change `enable.remote.storage` from `true` to `false` the topic will stop being archived, but the data which is already in remote storage won't be deleted.
   * If a person now disables tiered storage on a cluster-level there is nothing to let them know that they might have forgotten uncleaned data in remote storage.
   * If we forbid a topic to have the property then we draw the attention of the user to both situations where topics are still actively using remote storage and where topics have been disabled but remote data might still be present.
   * The way for them to express their certainty that they would like to proceed is to either completely remove the property or delete the topic.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1290107019


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   I actually prefer that we keep values from KafkaConfig (system-wide Tiered Storage configuration) and LogConfig (topic-specific Tiered Storage configuration) logically separate rather than insert one in the other. In other words, I would prefer that the validation between KafkaConfig(s) and LogConfig(s) happens in a place where values can be pulled from both and compared with one another (like what this PR is doing) until we introduce a mechanism of dependence between configurations from different sources.
   
   Of course, if I have missed a KRaft configuration which appears to have a similar logic as what we are trying to achieve here and it has been put in the LogConfig I can be persuaded to change my mind.
   
   My reasoning comes from default values (log.segment.bytes and log.segment.ms) in KafkaConfig being pulled from more specific configs (for example the segment.bytes and segment.ms) rather than the values from KafkaConfig being supplied to the LogConfig and being overwritten there.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1287005592


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   > Ah, I realised that this method is also called during startup and the `kafkaConfig.remoteLogManagerConfig` is not stored in Zk since it is not a dynamic config.
   > 
   > I was hoping we could do something like
   > 
   > https://github.com/apache/kafka/blob/8dec3e66163420ee0c2c259eef6e0c0f3185ca17/core/src/main/scala/kafka/server/KafkaConfig.scala#L2212
   > . This is because we currently don't perform config validation in ConfigHandler and I was hoping there is a better place to do it.
   > 
   > Let me think about it and will let you know if I have a better suggestion.
   
   I saw that as well, but the problem is that the topic configuration is a separate entity to the KafkaConfig. But sure, let me know if something else has your preference.



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1286890333


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   If you are referring to the `remote.log.storage.system.enable` property it is a read-only property and is only stored in server.properties (i.e. not in Zookeeper).



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1288285456


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,92 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_STORAGE_SYSTEM_ENABLE_PROP, true.toString)
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_LOG_METADATA_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteLogMetadataManager")
+    tsEnabledProps.put(RemoteLogManagerConfig.REMOTE_STORAGE_MANAGER_CLASS_NAME_PROP,
+      "org.apache.kafka.server.log.remote.storage.NoOpRemoteStorageManager")
+
+    val server = TestUtils.createServer(KafkaConfig.fromProps(tsEnabledProps))
+    server.remoteLogManagerOpt match {
+      case Some(_) =>
+      case None => fail("RemoteLogManager should be initialized")
+    }
+
+    val topicProps = new Properties()
+    topicProps.setProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG, true.toString)

Review Comment:
   That will indeed be useful. But perhaps is a separate PR so that we can use that method to replace config creation in other places as well.



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1288449342


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   lgtm



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1297412799


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   I have been looking at this a bit more and I don't think the current codebase invokes the validation path on pulling dynamic configurations. In other words, I believe there is client to broker validation, broker to metadata store validation, but once the data makes it in the metadata store we no longer carry out validation when we read it back from there. Unless I am wrong this means that we cannot unite these two approaches without big changes (system-wide needs to happen when we pull the dynamic configuration while the topic-specific needs to happen at broker to metadata store boundary). Am I wrong?



-- 
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] clolov commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "clolov (via GitHub)" <gi...@apache.org>.
clolov commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1297412799


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   ~~I have been looking at this a bit more and I don't think the current codebase invokes the validation path on pulling dynamic configurations. In other words, I believe there is client to broker validation, broker to metadata store validation, but once the data makes it in the metadata store we no longer carry out validation when we read it back from there. Unless I am wrong this means that we cannot unite these two approaches without big changes (system-wide needs to happen when we pull the dynamic configuration while the topic-specific needs to happen at broker to metadata store boundary). Am I wrong?~~



-- 
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] showuon commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294147126


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()
+      && topicConfig.getProperty(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG) != null) {

Review Comment:
   I'd disagree with this. Under this change, when the users set the topic level `enable.remote.storage=false` explicitly when creating a topic. Then, when disabling system-wide `remote.log.storage.system.enable=false` (or maybe they didn't enable it), the next startup will fail immediately with: 
   ```
   s"You have to delete all topics with the property remote.storage.enable (i.e. $topic) before disabling tiered storage cluster-wide"
   ```
   That doesn't make sense to me. 
   
   If you think we should notify users about this:
   ```
   Right now (and for 3.6) if I change enable.remote.storage from true to false the topic will stop being archived, but the data which is already in remote storage won't be deleted.
   ```
   I think we can add note in docs and logs when dynamically disabled topic-level `enable.remote.storage=false`, and make this check to `true` case.  WDYT?



-- 
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] showuon commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "showuon (via GitHub)" <gi...@apache.org>.
showuon commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294276490


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   It makes sense to me. But we also want to get consensus from all reviewers. 



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294983667


##########
core/src/test/scala/unit/kafka/server/KafkaServerTest.scala:
##########
@@ -154,6 +155,96 @@ class KafkaServerTest extends QuorumTestHarness {
     server.shutdown()
   }
 
+  @Test
+  def testClusterWideDisablementOfTieredStorageWithEnabledTieredTopic(): Unit = {
+    val tsEnabledProps = TestUtils.createBrokerConfigs(1, zkConnect).head

Review Comment:
   please add tests for kraft as well and for each case when broker is a controller, when broker is a KraftServer and when broker is a ZkServer. Asking because some of the initialization code path varies amongst them and we can't be sure that the config validation is always called correctly in the future as well.



-- 
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] divijvaidya commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1294994048


##########
core/src/main/scala/kafka/server/ConfigHandler.scala:
##########
@@ -62,6 +62,12 @@ class TopicConfigHandler(private val logManager: LogManager, kafkaConfig: KafkaC
     topicConfig.asScala.forKeyValue { (key, value) =>
       if (!configNamesToExclude.contains(key)) props.put(key, value)
     }
+
+    if (!kafkaConfig.remoteLogManagerConfig.enableRemoteStorageSystem()

Review Comment:
   With this change we are splitting the logic of system-wide and topic-specific config at two places. One in LogConfig and this one in ConfigHandler. Could we choose to stick to one of them? I don't have a strong opinion on which one as long as it's at one consolidated place. 



-- 
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] kamalcph commented on a diff in pull request #14161: KAFKA-15267: Do not allow Tiered Storage to be disabled while topics have remote.storage.enable property

Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #14161:
URL: https://github.com/apache/kafka/pull/14161#discussion_r1300316787


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogConfig.java:
##########
@@ -500,22 +500,29 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props,
      * The default values should be extracted from the KafkaConfig.
      * @param props The properties to be validated
      */
-    private static void validateTopicLogConfigValues(Map<?, ?> props,
-                                                     boolean isRemoteLogStorageSystemEnabled) {
+    public static void validateTopicLogConfigValues(Map<?, ?> props,

Review Comment:
   Can we supply the `props` as parameter to `validateRemoteStorageOnlyIfSystemEnabled` method and call it directly from LogManager?



-- 
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