mumrah commented on code in PR #14169:
URL: https://github.com/apache/kafka/pull/14169#discussion_r1288505525


##########
metadata/src/main/java/org/apache/kafka/controller/AclControlManager.java:
##########
@@ -256,11 +224,6 @@ public void replay(
             throw new RuntimeException("Unable to replay " + record + " for " 
+ acl +
                 ": acl not found " + "in existingAcls.");
         }
-        if (!snapshotId.isPresent()) {

Review Comment:
   Nice to see this code going away. It always tripped me up 😅 



##########
core/src/main/scala/kafka/server/metadata/AclPublisher.scala:
##########
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package kafka.server.metadata
+
+import kafka.utils.Logging
+import org.apache.kafka.image.loader.LoaderManifest
+import org.apache.kafka.image.{MetadataDelta, MetadataImage}
+import org.apache.kafka.metadata.authorizer.ClusterMetadataAuthorizer
+import org.apache.kafka.server.authorizer.Authorizer
+import org.apache.kafka.server.fault.FaultHandler
+
+import scala.concurrent.TimeoutException
+
+
+class AclPublisher(
+  id: Int,
+  faultHandler: FaultHandler,
+  nodeType: String,
+  authorizer: Option[Authorizer],
+) extends Logging with org.apache.kafka.image.publisher.MetadataPublisher {
+  logIdent = s"[${name()}] "
+
+  override def name(): String = s"AclPublisher ${nodeType} id=${id}"
+
+  var completedInitialLoad = false
+
+  override def onMetadataUpdate(
+    delta: MetadataDelta,
+    newImage: MetadataImage,
+    manifest: LoaderManifest
+  ): Unit = {
+    val deltaName = s"MetadataDelta up to ${newImage.offset()}"
+
+    // Apply changes to ACLs. This needs to be handled carefully because while 
we are
+    // applying these changes, the Authorizer is continuing to return 
authorization
+    // results in other threads. We never want to expose an invalid state. For 
example,
+    // if the user created a DENY ALL acl and then created an ALLOW ACL for 
topic foo,
+    // we want to apply those changes in that order, not the reverse order! 
Otherwise
+    // there could be a window during which incorrect authorization results 
are returned.
+    Option(delta.aclsDelta()).foreach { aclsDelta =>
+      authorizer match {
+        case Some(authorizer: ClusterMetadataAuthorizer) => if 
(aclsDelta.isSnapshotDelta) {

Review Comment:
   Since we have the manifest here, we can remove this `isSnapshotDelta` from 
AclsDelta



##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -1112,35 +1102,12 @@ private void appendRaftEvent(String name, Runnable 
runnable) {
                 if (this != metaLogListener) {
                     log.debug("Ignoring {} raft event from an old 
registration", name);
                 } else {
-                    try {
-                        runnable.run();
-                    } finally {
-                        maybeCompleteAuthorizerInitialLoad();
-                    }
+                    runnable.run();
                 }
             });
         }
     }
 
-    private void maybeCompleteAuthorizerInitialLoad() {

Review Comment:
   The equivalent logic to this is handled by MetadataLoader, right? (not 
publishing until we've reached the HWM)



##########
core/src/main/scala/kafka/server/metadata/AclPublisher.scala:
##########
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package kafka.server.metadata
+
+import kafka.utils.Logging
+import org.apache.kafka.image.loader.LoaderManifest
+import org.apache.kafka.image.{MetadataDelta, MetadataImage}
+import org.apache.kafka.metadata.authorizer.ClusterMetadataAuthorizer
+import org.apache.kafka.server.authorizer.Authorizer
+import org.apache.kafka.server.fault.FaultHandler
+
+import scala.concurrent.TimeoutException
+
+
+class AclPublisher(
+  id: Int,

Review Comment:
   nit: `nodeId` instead of just `id`?



##########
metadata/src/main/java/org/apache/kafka/controller/AclControlManager.java:
##########
@@ -256,11 +224,6 @@ public void replay(
             throw new RuntimeException("Unable to replay " + record + " for " 
+ acl +
                 ": acl not found " + "in existingAcls.");
         }
-        if (!snapshotId.isPresent()) {

Review Comment:
   Nice to see this code going away. It always tripped me up 😅 



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