Skip to content

KAFKA-17897: Deprecate Admin.listConsumerGroups [2/N] #19508

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 6 commits into
base: trunk
Choose a base branch
from

Conversation

AndrewJSchofield
Copy link
Member

@AndrewJSchofield AndrewJSchofield commented Apr 17, 2025

Admin.listConsumerGroups() was able to use the early versions of
ListGroups RPC with the version used dependent upon the filters the user
specified. Admin.listGroups(ListGroupsOptions.forConsumerGroups())
inadvertently required ListGroups v5 because it always set a types
filter. This patch handles the UnsupportedVersionException and winds
back the complexity of the request unless the user has specified filters
which demand a higher version.

It also adds ListGroupsOptions.forShareGroups() and forStreamsGroups().
The usability of Admin.listGroups() is much improved as a result.

Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

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

@AndrewJSchofield Thanks for the PR. I have a question about last change (#19477) of Jira (KAFKA-17897). In KIP-1043, it mentioned kafka-consumer-groups.sh gives an error message when a group is not a consumer group. However, it can be used to list share / stream groups like:

./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list --type classic,consumer,share,streams

Do we want to have an error message for this case? Thanks.

Screenshot 2025-04-18 at 7 47 40 PM

@AndrewJSchofield
Copy link
Member Author

@FrankYang0529 That's an interesting point. I'll put in a change to kafka-consumer-groups.sh in this PR soon. Thanks for the catch.


// If only regular consumer group types are required, we can try an earlier request version if
// UnsupportedVersionException is thrown
final boolean canTryEarlierRequestVersion = options.regularConsumerGroupTypes();
Copy link
Member

Choose a reason for hiding this comment

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

Instead of re-sending the request, maybe we can modify the request (ListGroupsRequest.Builder#build) when the version is small than v5?

            if (!data.typesFilter().isEmpty() && version < 5) {
                var copy = new HashSet<>(data.typesFilter());
                copy.remove(GroupType.CLASSIC.toString());
                copy.remove(GroupType.CONSUMER.toString());
                if (!copy.isEmpty())
                    throw new UnsupportedVersionException("The broker only supports ListGroups v" + version + ", but we need v5 or newer to request groups by type.");
                return new ListGroupsRequest(data.duplicate().setTypesFilter(List.of()), version);
            }

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've taken this suggestion and tweaked it a bit.

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

Successfully merging this pull request may close these issues.

3 participants