aglicacha commented on code in PR #12729: URL: https://github.com/apache/kafka/pull/12729#discussion_r996423424
########## core/src/main/scala/kafka/zk/AdminZkClient.scala: ########## @@ -365,6 +365,29 @@ class AdminZkClient(zkClient: KafkaZkClient) extends Logging { case ConfigType.Ip => changeIpConfig(entityName, configs) case _ => throw new IllegalArgumentException(s"$entityType is not a known entityType. Should be one of ${ConfigType.all}") } + + if ((ConfigType.Client.equals(entityType) || ConfigType.User.equals(entityType) || ConfigType.Ip.equals(entityType)) && configs.isEmpty) { + val currPath = ConfigEntityZNode.path(entityType, entityName) + if (zkClient.getChildren(currPath).isEmpty) { + var pathToDelete = currPath + if (isUserClientId) { + val user = entityName.substring(0, entityName.indexOf("/")) + val clientId = entityName.substring(entityName.lastIndexOf("/") + 1) + val clientsPath = ConfigEntityZNode.path(ConfigType.User, user + "/" + ConfigType.Client) + val clientsChildren = zkClient.getChildren(clientsPath) + if (clientsChildren.size == 1 && clientsChildren.head.equals(clientId)) { Review Comment: Done. ########## core/src/main/scala/kafka/zk/AdminZkClient.scala: ########## @@ -365,6 +365,29 @@ class AdminZkClient(zkClient: KafkaZkClient) extends Logging { case ConfigType.Ip => changeIpConfig(entityName, configs) case _ => throw new IllegalArgumentException(s"$entityType is not a known entityType. Should be one of ${ConfigType.all}") } + + if ((ConfigType.Client.equals(entityType) || ConfigType.User.equals(entityType) || ConfigType.Ip.equals(entityType)) && configs.isEmpty) { + val currPath = ConfigEntityZNode.path(entityType, entityName) + if (zkClient.getChildren(currPath).isEmpty) { + var pathToDelete = currPath + if (isUserClientId) { + val user = entityName.substring(0, entityName.indexOf("/")) + val clientId = entityName.substring(entityName.lastIndexOf("/") + 1) + val clientsPath = ConfigEntityZNode.path(ConfigType.User, user + "/" + ConfigType.Client) + val clientsChildren = zkClient.getChildren(clientsPath) + if (clientsChildren.size == 1 && clientsChildren.head.equals(clientId)) { + pathToDelete = clientsPath + val userData = fetchEntityConfig(ConfigType.User, user) + val userPath = ConfigEntityZNode.path(ConfigType.User, user) + val userChildren = zkClient.getChildren(userPath) + if (userData.isEmpty && userChildren.size == 1 && userChildren.head.equals(ConfigType.Client)) { Review Comment: Done. -- 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