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


##########
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:
   Agree with that. It may be better to do this logic in AdminZkClient. I have 
moved it to AdminZkClient and added corresponding tests. 
   Thank you.



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