You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/10/08 18:05:49 UTC

[GitHub] [kafka] soarez commented on a diff in pull request #12727: KAFKA-14285: Delete quota node in zookeeper when configs are empty

soarez commented on code in PR #12727:
URL: https://github.com/apache/kafka/pull/12727#discussion_r990671188


##########
core/src/main/scala/kafka/server/ZkAdminManager.scala:
##########
@@ -779,8 +780,30 @@ class ZkAdminManager(val config: KafkaConfig,
           }
         }
       }
-      if (!validateOnly)
+      if (!validateOnly) {
         adminZkClient.changeConfigs(configType, path, props)
+        if (props.isEmpty) {
+          // try to clean empty quota nodes
+          val currPath = ConfigEntityZNode.path(configType, path)
+          if (zkClient.getChildren(currPath).isEmpty) {
+            var pathToDelete = currPath
+            if (userClientQuota) {
+              val clientsPath = ConfigEntityZNode.path(ConfigType.User, userOpt.get + "/" + ConfigType.Client)
+              val clientsChildren = zkClient.getChildren(clientsPath)
+              if (clientsChildren.size == 1 && clientsChildren.head.equals(clientIdOpt.get)) {
+                pathToDelete = clientsPath
+                val userData = adminZkClient.fetchEntityConfig(ConfigType.User, userOpt.get)
+                val userPath = ConfigEntityZNode.path(ConfigType.User, userOpt.get)
+                val userChildren = zkClient.getChildren(userPath)
+                if (userData.isEmpty && userChildren.size == 1 && userChildren.head.equals(ConfigType.Client)) {
+                  pathToDelete = userPath
+                }
+              }
+            }
+            zkClient.deletePath(pathToDelete)
+          }
+        }
+      }

Review Comment:
   It seems to me that `ZkAdminManager` is not the right place for this logic, it might make more sense to have this in `AdminZkClient`, perhaps in `hangeConfigs()` or `changeUserOrUserClientIdConfig()`. 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