akhileshchg commented on code in PR #15744:
URL: https://github.com/apache/kafka/pull/15744#discussion_r1569190991


##########
core/src/main/scala/kafka/zk/KafkaZkClient.scala:
##########
@@ -467,13 +470,33 @@ class KafkaZkClient private[zk] (zooKeeperClient: 
ZooKeeperClient, isSecure: Boo
    * @param rootEntityType entity type
    * @param sanitizedEntityName entity name
    * @throws KeeperException if there is an error while setting or creating 
the znode
+   * @throws ControllerMovedException if no controller is defined, or a KRaft 
controller is defined
    */
   def setOrCreateEntityConfigs(rootEntityType: String, sanitizedEntityName: 
String, config: Properties): Unit = {
+    val controllerRegistration = getControllerRegistration match {
+      case Some(registration) => registration
+      case None =>
+        // This case is mainly here to make tests less flaky. In practice, 
there will always be a /controller ZNode
+        throw new ControllerMovedException(s"Cannot set entity configs when 
there is no controller.")
+    }
+
+    // If there is a KRaft controller defined, don't even attempt this write. 
The broker will soon get a UMR
+    // from the new KRaft controller that lets it know about the new 
controller. It will then forward
+    // IncrementalAlterConfig requests instead of processing directly.
+    if (controllerRegistration.kraftEpoch.exists(epoch => epoch > 0)) {
+      throw new ControllerMovedException(s"Cannot set entity configs directly 
when there is a KRaft controller.")
+    }

Review Comment:
   Wouldn't this fail when KRaft controller tries to perform dual write to both 
KRaft log and Zk ?



##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -3003,9 +3008,10 @@ class KafkaApis(val requestChannel: RequestChannel,
       }
     }
 
+    // Forwarding has not happened yet, so handle both ZK and KRaft cases here
     if (remaining.resources().isEmpty) {
       sendResponse(Some(new IncrementalAlterConfigsResponseData()))
-    } else if ((!request.isForwarded) && metadataSupport.canForward()) {
+    } else if ((!request.isForwarded) && metadataSupport.canForward() && 
isKRaftController) {

Review Comment:
   I have one question. Why can't the Zk controller take care of the forwarded 
alterConfig requests for other BROKER config entities?



-- 
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-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to