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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to