Current state: Accepted
Discussion thread: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
At the moment, the ListGroups API always returns all groups. There are metrics that track the number of groups in several states but the only way to know the state of a group is to describe it using the DescribeGroups API. In large clusters with hundreds or thousands of groups, it can be hard for a cluster administrator to identify which groups are stable or which groups are dead and can be deleted for example. Basically this requires describing a large number of groups which is inefficient in terms of time for the administrator and load for the cluster.
To improve that use case, I propose to allow listing groups by state. For example listing stable groups allows to immediately tell if several applications are healthy if their groups are all returned without needing to describe each group. This would allow building tools and user interfaces that can easily and quickly display informations about live groups.
Bump ListGroupsRequest version to 4 and include a new field "StatesFilter".
Bump ListGroupsResponse version to 4 and include a new field "GroupState".
This KIP bumps the version of this request to avoid any version incompatibility issues with older broker. See rejected alternatives.
If the version is 4 or above, if StatesFilter is empty in the request all groups will be returned with their states. If StatesFilter is set to a list of group states, only states that are currently in these states will be returned. At the moment, consumer group state is already serialized as a STRING in DescribeGroupsResponse, so serializing it the same way here.
When attempting to list groups with states using an older broker, an UnsupportedVersionException will be raised in the client.
To expose this feature in the AdminClient API, ListConsumerGroupsOptions will be updated.
Similarly, a state field will be exposed in ConsumerGroupListing:
The state will be empty when ListGroupsRequest < 3 is used, for example when connecting to an older broker.
Command line tools
To expose this feature in the command line tools, ConsumerGroupCommand tool will be updated to support filtering by group states. The existing flag "--state" will be updated to allow specifying a list of group states when used with "–list". When specified, the state of each group will be printed along the group id.
Compatibility, Deprecation, and Migration Plan
With this KIP, having Describe authorization on the Cluster resource allows to retrieve the state of all groups. Previously this required having Describe authorization on each Group.
- Allow specifying a filter in ListGroups to retrieve groups by name or by state using wildcard
- Unclear if it's a common use case
- Add flexible fields without bumping the ListGroups version
- Keeping v3 would allow cases where brokers could support v3 but not the new optional field. In that case, if a client specifies states in its request, brokers would still return the full list of groups without states. This looked confusing. In case broker don't support a feature, a UnsupportedVersionException is preferred.