You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2025/05/25 05:52:28 UTC

[PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

FrankYang0529 opened a new pull request, #19808:
URL: https://github.com/apache/kafka/pull/19808

   * Return resource doesn't exist message when users try to describe a non-existent resource in kafka-configs.sh and kafka-client-metrics.sh.
   * For groups type, the command checks both existent groups and non-existent groups but having dynamic config. If it cannot find a group in both conditions, return resource doesn't exist message.


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


Re: [PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #19808:
URL: https://github.com/apache/kafka/pull/19808#issuecomment-2920322851

   not sure if I overlooked the vote, but the vote does not pass yet (https://lists.apache.org/thread/bmr5l38gfnqrws3qfpxqfp7y9r7lzdrc). Is there another vote thread?


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


Re: [PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

Posted by "AndrewJSchofield (via GitHub)" <gi...@apache.org>.
AndrewJSchofield merged PR #19808:
URL: https://github.com/apache/kafka/pull/19808


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


Re: [PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

Posted by "DL1231 (via GitHub)" <gi...@apache.org>.
DL1231 commented on code in PR #19808:
URL: https://github.com/apache/kafka/pull/19808#discussion_r2106900047


##########
clients/src/test/java/org/apache/kafka/clients/admin/AdminClientTestUtils.java:
##########
@@ -163,6 +164,15 @@ public static ListConsumerGroupOffsetsResult listConsumerGroupOffsetsResult(Stri
         return new ListConsumerGroupOffsetsResult(Collections.singletonMap(CoordinatorKey.byGroupId(group), future));
     }
 
+    public static ListConfigResourcesResult listConfigResourcesResult(Map<ConfigResource.Type, Set<String>> resourceNames) {
+        Collection<ConfigResource> resources = resourceNames.entrySet().stream()
+            .flatMap(entry -> entry.getValue().stream()
+                .map(name -> new ConfigResource(entry.getKey(), name)))
+            .collect(Collectors.toList());
+        return new ListConfigResourcesResult(KafkaFuture.completedFuture(resources));
+

Review Comment:
   nit: extra blank



##########
core/src/main/scala/kafka/admin/ConfigCommand.scala:
##########
@@ -342,6 +342,42 @@ object ConfigCommand extends Logging {
   }
 
   private def describeResourceConfig(adminClient: Admin, entityType: String, entityName: Option[String], describeAll: Boolean): Unit = {
+    if (!describeAll) {
+      entityName.foreach { name =>
+        entityType match {
+          case TopicType =>
+            Topic.validate(name)
+            if (!adminClient.listTopics(new ListTopicsOptions().listInternal(true)).names.get.contains(name)) {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")
+              return
+            }
+          case BrokerType | BrokerLoggerConfigType =>
+            if (adminClient.describeCluster.nodes.get.stream.anyMatch(_.idString == name)) {
+              // valid broker id
+            } else if (name == BrokerDefaultEntityName) {
+              // default broker configs
+            } else {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")
+              return
+            }
+          case ClientMetricsType =>
+            if (adminClient.listConfigResources(java.util.Set.of(ConfigResource.Type.CLIENT_METRICS), new ListConfigResourcesOptions).all.get

Review Comment:
   nit: Can't this just be util.Set.of?



##########
core/src/main/scala/kafka/admin/ConfigCommand.scala:
##########
@@ -342,6 +342,42 @@ object ConfigCommand extends Logging {
   }
 
   private def describeResourceConfig(adminClient: Admin, entityType: String, entityName: Option[String], describeAll: Boolean): Unit = {
+    if (!describeAll) {
+      entityName.foreach { name =>
+        entityType match {
+          case TopicType =>
+            Topic.validate(name)
+            if (!adminClient.listTopics(new ListTopicsOptions().listInternal(true)).names.get.contains(name)) {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")
+              return
+            }
+          case BrokerType | BrokerLoggerConfigType =>
+            if (adminClient.describeCluster.nodes.get.stream.anyMatch(_.idString == name)) {
+              // valid broker id
+            } else if (name == BrokerDefaultEntityName) {
+              // default broker configs
+            } else {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")
+              return
+            }
+          case ClientMetricsType =>
+            if (adminClient.listConfigResources(java.util.Set.of(ConfigResource.Type.CLIENT_METRICS), new ListConfigResourcesOptions).all.get
+              .stream.noneMatch(_.name == name)) {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")
+              return
+            }
+          case GroupType =>
+            if (adminClient.listGroups().all.get.stream.noneMatch(_.groupId() == name) &&
+              adminClient.listConfigResources(java.util.Set.of(ConfigResource.Type.GROUP), new ListConfigResourcesOptions).all.get

Review Comment:
   ditto



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


Re: [PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #19808:
URL: https://github.com/apache/kafka/pull/19808#issuecomment-2920330117

   > not sure if I overlooked the vote, but the vote does not pass yet (https://lists.apache.org/thread/bmr5l38gfnqrws3qfpxqfp7y9r7lzdrc). Is there another vote thread?
   
   Sorry that I checked on the wrong thread :(


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


Re: [PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on code in PR #19808:
URL: https://github.com/apache/kafka/pull/19808#discussion_r2107254802


##########
core/src/main/scala/kafka/admin/ConfigCommand.scala:
##########
@@ -342,6 +342,42 @@ object ConfigCommand extends Logging {
   }
 
   private def describeResourceConfig(adminClient: Admin, entityType: String, entityName: Option[String], describeAll: Boolean): Unit = {
+    if (!describeAll) {
+      entityName.foreach { name =>
+        entityType match {
+          case TopicType =>
+            Topic.validate(name)
+            if (!adminClient.listTopics(new ListTopicsOptions().listInternal(true)).names.get.contains(name)) {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")
+              return
+            }
+          case BrokerType | BrokerLoggerConfigType =>
+            if (adminClient.describeCluster.nodes.get.stream.anyMatch(_.idString == name)) {
+              // valid broker id
+            } else if (name == BrokerDefaultEntityName) {
+              // default broker configs
+            } else {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")
+              return
+            }
+          case ClientMetricsType =>
+            if (adminClient.listConfigResources(java.util.Set.of(ConfigResource.Type.CLIENT_METRICS), new ListConfigResourcesOptions).all.get

Review Comment:
   I prefer to leave this as `java.util.xxx` because we already used this pattern like:
   
   https://github.com/apache/kafka/blob/48a52701b9cd45c4854f910990a85be7d73e22f5/core/src/main/scala/kafka/admin/ConfigCommand.scala#L311
   
   We can do some refactor for Scala code in core module after this PR. Or we can refactor it when migrating to Java eventually.



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


Re: [PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

Posted by "AndrewJSchofield (via GitHub)" <gi...@apache.org>.
AndrewJSchofield commented on code in PR #19808:
URL: https://github.com/apache/kafka/pull/19808#discussion_r2112143179


##########
core/src/main/scala/kafka/admin/ConfigCommand.scala:
##########
@@ -342,6 +342,42 @@ object ConfigCommand extends Logging {
   }
 
   private def describeResourceConfig(adminClient: Admin, entityType: String, entityName: Option[String], describeAll: Boolean): Unit = {
+    if (!describeAll) {
+      entityName.foreach { name =>
+        entityType match {
+          case TopicType =>
+            Topic.validate(name)
+            if (!adminClient.listTopics(new ListTopicsOptions().listInternal(true)).names.get.contains(name)) {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")

Review Comment:
   Alternatively, and this is what they do elsewhere in this tool, use `${entityType.dropRight(1)}`.



##########
core/src/main/scala/kafka/admin/ConfigCommand.scala:
##########
@@ -342,6 +342,42 @@ object ConfigCommand extends Logging {
   }
 
   private def describeResourceConfig(adminClient: Admin, entityType: String, entityName: Option[String], describeAll: Boolean): Unit = {
+    if (!describeAll) {
+      entityName.foreach { name =>
+        entityType match {
+          case TopicType =>
+            Topic.validate(name)
+            if (!adminClient.listTopics(new ListTopicsOptions().listInternal(true)).names.get.contains(name)) {
+              System.out.println(s"The $entityType '$name' doesn't exist and doesn't have dynamic config.")

Review Comment:
   The variable `entityType` contains the pluralized noun such as topics or groups. As a result, the message is not grammatical, for example `The groups 'G2' doesn't exist and doesn't have dynamic config.`. This problem is evident for all entity types.
   
   Probably easiest here is just to use a slightly different string for each type such as `s"The topic '$name' doesn't exist and doesn't have dynamic config."`.



##########
tools/src/main/java/org/apache/kafka/tools/ClientMetricsCommand.java:
##########
@@ -156,6 +156,12 @@ public void describeClientMetrics(ClientMetricsCommandOptions opts) throws Excep
 
             List<String> entities;
             if (entityNameOpt.isPresent()) {
+                if (adminClient.listConfigResources(Set.of(ConfigResource.Type.CLIENT_METRICS), new ListConfigResourcesOptions())
+                        .all().get(30, TimeUnit.SECONDS).stream()
+                        .noneMatch(resource -> resource.name().equals(entityNameOpt.get()))) {
+                    System.out.println("The client-metric " + entityNameOpt.get() + " doesn't exist and doesn't have dynamic config.");

Review Comment:
   I think I'd use `client metrics resource`. This is the terminology in the usage message for this tool. It's a bit of a mouthful, but `client-metric` sounds like a metric from a client, not something uses to configure them.



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


Re: [PR] KAFKA-18904: kafka-configs.sh return resource doesn't exist message [3/N] [kafka]

Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on PR #19808:
URL: https://github.com/apache/kafka/pull/19808#issuecomment-2920872415

   I think there are two threads:
   
   * https://lists.apache.org/thread/bmr5l38gfnqrws3qfpxqfp7y9r7lzdrc
   * https://lists.apache.org/thread/nnnfxftg5954xdvkwg3okhrlxw32wk1l


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