Visitar URL original
feat(gateways): Kafka Gateway add DescribeGroups and ListGroups Keys by ryerraguntla · Pull Request #4401 · apache/iggy · GitHub
Skip to content

feat(gateways): Kafka Gateway add DescribeGroups and ListGroups Keys - #4401

Open
ryerraguntla wants to merge 9 commits into
masterfrom
feat/gateways-3548-describe-list-groups
Open

ryerraguntla wants to merge 9 commits into
masterfrom
feat/gateways-3548-describe-list-groups

Conversation

@ryerraguntla

Copy link
Copy Markdown
Contributor

Which issue does this PR address?

Closes #3548
Relates #3560

Rationale

kafka-consumer-groups.sh and other admin clients learn classic group membership by sending DescribeGroups and ListGroups. This gateway already coordinates those groups in memory for join, heartbeat, sync, and leave, and nothing on the wire would report that state, so those tools could not inspect a group on this coordinator.

What changed?

DescribeGroups versions 0-6 and ListGroups versions 0-5 now read that same in-memory coordinator. A live group is PreparingRebalance, CompletingRebalance, or Stable. A named group that is not in the map is Dead. Version 6 also returns GROUP_ID_NOT_FOUND (69) and Group {id} not found.. Older describe versions return Dead with error 0, because a v6 client treats error 0 as a group that exists.

Each member includes its id, its instance id, the subscription metadata of the selected protocol, and its assignment bytes. client_id and client_host stay empty, because the coordinator does not retain the request header's client id or the connection's peer address. include_authorized_operations stays at the omitted sentinel. There is no group ACL bitfield. ListGroups sets group_type to classic. From v4 a state filter, and from v5 a type filter, keep a group only when the filter is empty or one entry matches, case-insensitively after trim. A filter value this coordinator does not use matches nothing, and the response error stays 0.

ListGroups does not expire sessions. Expiry runs on a request that names a group, and a list names none, so listing must not open rebalances as a side effect of reading. DescribeGroups ticks each named group once, after the requested ids are deduped, so a repeated id is one group and one tick. The describe frame is priced from lengths already stored, before any member snapshot is copied. If that body would exceed max_frame_size, the connection closes. An oversized ListGroups body closes the same way. The list is priced before it is encoded, because the request shape guard never sees the groups that will be written back.

Join rejects a protocol_type, a client-supplied member_id, or a group_instance_id longer than i16::MAX. DescribeGroups v0-v4 and ListGroups v0-v2 encode those fields as legacy strings, and a longer value cannot be written back. When the member id is generated, the instance id is the prefix and 37 bytes are reserved for -{uuid}, so the id itself still fits that cap. A failed DescribeGroups decode closes the connection: the response has no top-level error field, and an empty group list would look like success. A failed ListGroups decode returns INVALID_REQUEST (42). Groups stay in process memory only. A restart drops membership. Committed offsets stay in Iggy.

Local Execution

  • Passed:
  • cargo fmt -p iggy-gateway-kafka (exit 0);
  • cargo test -p iggy-gateway-kafka --lib group:: (79 passed);
  • cargo test -p iggy-gateway-kafka --test consumer_group_tests (44 passed);
  • cargo clippy -p iggy-gateway-kafka --all-targets -- -D warnings

AI Usage

If AI tools were used, please answer:

  1. Which tools? Claude
  2. Scope of usage? Implementation
  3. How did you verify the generated code works correctly?Manual walkthrough, testing
  4. Can you explain every line of the code if asked? Yes

@ryerraguntla
ryerraguntla requested a balanced review from Copilot October 5, 2026 00:58
@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Oct 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Overlong protocol names can break legacy DescribeGroups encoding, and the required admin-tool integration coverage is missing.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Adds Kafka DescribeGroups and ListGroups support backed by the gateway’s in-memory group coordinator.

Changes:

  • Implements API versions 0–6 and 0–5 with filtering and response-size guards.
  • Exposes group state, membership, metadata, and assignments.
  • Adds protocol tests and updates gateway documentation.
File Description
gateways/​kafka/​src/​group/​mod.rs Adds group snapshot/listing models and APIs.
gateways/​kafka/​src/​group/​state.rs Implements snapshots, sizing, listing, and validation.
gateways/​kafka/​src/​protocol/​api.rs Registers keys 15 and 16.
gateways/​kafka/​src/​protocol/​bounds_guard.rs Validates both request shapes.
gateways/​kafka/​src/​protocol/​handlers/​mod.rs Dispatches the new APIs.
gateways/​kafka/​src/​protocol/​handlers/​describe_groups.rs Implements DescribeGroups.
gateways/​kafka/​src/​protocol/​handlers/​list_groups.rs Implements ListGroups.
gateways/​kafka/​tests/​common/​scope.rs Adds supported version ranges.
gateways/​kafka/​tests/​common/​wire.rs Adds request builders.
gateways/​kafka/​tests/​consumer_group_tests.rs Tests group descriptions and listings.
gateways/​kafka/​tests/​golden_wire_fixtures_tests.rs Updates ApiVersions fixtures.
gateways/​kafka/​tests/​server_e2e_tests.rs Expands unsupported-key coverage.
gateways/​kafka/​tests/​version_firewall_tests.rs Tests advertised versions.
gateways/​kafka/​README.md Documents admin group views.
gateways/​kafka/​docs/​CONSUMER_GROUPS.md Documents API behavior.
gateways/​kafka/​docs/​MANUAL_TESTING.md Updates manual test cases.
gateways/​kafka/​docs/​SCOPE.md Marks both APIs supported.
gateways/​kafka/​docs/​TEST_SUITE.md Updates test coverage documentation.
gateways/​kafka/​docs/​kafka_api_keys_reference.md Updates API support status.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread gateways/kafka/src/group/state.rs Outdated
Comment thread gateways/kafka/tests/consumer_group_tests.rs
@ryerraguntla

Copy link
Copy Markdown
Contributor Author

/skill team-review-slim

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary: DescribeGroups (15) and ListGroups (16) are now real handlers over the in-memory coordinator, with hand-computed response pricing and a new legacy-string cap on JoinGroup. Three defects stand out: the cap misses protocol names that DescribeGroups v0-v4 encode as an i16-length string, ListGroups closes rather than truncates a server-sized response a peer can inflate, and unsupported_api_keys_close_connection still expects key 16 to close. The rest are small cleanups.

Counts: critical 1, warning 2, nit 1, simplification 4

Findings without an anchor on a changed line:

  • gateways/kafka/tests/version_firewall_tests.rs critical: dispatch now routes api key 16 to list_groups::handle, and an empty v0 ListGroups body decodes and gets a response. unsupported_api_keys_close_connection still expects key 16 to close, so that assertion fails. Drop 16 from the list at version_firewall_tests.rs:355, and 15 with it, because neither key is unsupported now.

This review was generated by Claude Code 2.1.284 on deepseek-flash[1m]. Review the output before you act on it.

Comment thread gateways/kafka/src/group/state.rs
Comment thread gateways/kafka/src/protocol/handlers/list_groups.rs Outdated
Comment thread gateways/kafka/src/group/mod.rs Outdated
Comment thread gateways/kafka/src/group/mod.rs Outdated
Comment thread gateways/kafka/src/protocol/handlers/list_groups.rs Outdated
Comment thread gateways/kafka/src/protocol/handlers/describe_groups.rs Outdated
Comment thread gateways/kafka/src/protocol/handlers/describe_groups.rs Outdated
@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Oct 5, 2026
@ryerraguntla

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Oct 5, 2026
Comment thread gateways/kafka/src/protocol/handlers/describe_groups.rs Outdated
Comment thread gateways/kafka/src/group/state.rs Outdated
Comment thread gateways/kafka/src/group/state.rs Outdated
Comment thread gateways/kafka/src/group/state.rs
Comment thread gateways/kafka/src/group/mod.rs
Comment thread gateways/kafka/src/protocol/handlers/list_groups.rs
Comment thread gateways/kafka/README.md
@ryerraguntla

Copy link
Copy Markdown
Contributor Author

/author

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Oct 7, 2026
@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.45%. Comparing base (5ded8ff) to head (8cea689).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4401      +/-   ##
============================================
+ Coverage     87.85%   88.45%   +0.60%     
+ Complexity     1608     1579      -29     
============================================
  Files          1294     1287       -7     
  Lines        249269   246070    -3199     
  Branches     209776   209484     -292     
============================================
- Hits         218995   217663    -1332     
+ Misses        25024    23282    -1742     
+ Partials       5250     5125     -125     
Components Coverage Δ
Rust Core 89.57% <ø> (+0.02%) ⬆️
Java SDK 68.71% <ø> (-0.11%) ⬇️
C# SDK 77.60% <ø> (+15.07%) ⬆️
Python SDK 91.16% <ø> (+0.09%) ⬆️
PHP SDK 85.67% <ø> (ø)
Node SDK 96.59% <ø> (-0.01%) ⬇️
Go SDK 70.19% <ø> (-0.10%) ⬇️
C++ SDK ∅ <ø> (∅)
see 129 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ryerraguntla

Copy link
Copy Markdown
Contributor Author

/ready

@github-actions github-actions Bot added S-waiting-on-review PR is waiting on a reviewer and removed S-waiting-on-author PR is waiting on author response labels Oct 8, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kafka gateway: Kafka DescribeGroups and ListGroups admin APIs

4 participants