Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

FrankYang0529
Copy link
Member

@FrankYang0529 FrankYang0529 commented May 25, 2025

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

Copy link
Contributor

@DL1231 DL1231 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FrankYang0529 Thanks for the PR, overall LGTM.

.map(name -> new ConfigResource(entry.getKey(), name)))
.collect(Collectors.toList());
return new ListConfigResourcesResult(KafkaFuture.completedFuture(resources));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra blank

return
}
case ClientMetricsType =>
if (adminClient.listConfigResources(java.util.Set.of(ConfigResource.Type.CLIENT_METRICS), new ListConfigResourcesOptions).all.get
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to leave this as java.util.xxx because we already used this pattern like:

val alterEntityMap = new java.util.HashMap[String, String]

We can do some refactor for Scala code in core module after this PR. Or we can refactor it when migrating to Java eventually.

}
case GroupType =>
if (adminClient.listGroups().all.get.stream.noneMatch(_.groupId() == name) &&
adminClient.listConfigResources(java.util.Set.of(ConfigResource.Type.GROUP), new ListConfigResourcesOptions).all.get
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

@DL1231 DL1231 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@AndrewJSchofield AndrewJSchofield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. It works nicely. A few comments about the grammar of the output messages, but looks good apart from that.

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.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants