Skip to content

Fix: Handle partial consumer group lag calculation failures#2574

Open
ngyngcphu wants to merge 1 commit into
redpanda-data:masterfrom
ngyngcphu:fix/consumer-group-partial-offset-errors
Open

Fix: Handle partial consumer group lag calculation failures#2574
ngyngcphu wants to merge 1 commit into
redpanda-data:masterfrom
ngyngcphu:fix/consumer-group-partial-offset-errors

Conversation

@ngyngcphu

Copy link
Copy Markdown

Fixed #2573
Related to #2327

Before fix, run test TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure, got error:

go test ./pkg/console -run '^TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure$' -count=1 -timeout=3m -v                           ─╯

=== RUN   TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure
=== RUN   TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/listener_not_found
    consumer_group_offsets_test.go:296:
                Error Trace:    /Users/lap60627/Documents/PTO/console/backend/pkg/console/consumer_group_offsets_test.go:296
                Error:          Received unexpected error:
                                failed to list end offsets for topics: LISTENER_NOT_FOUND: There is no listener on the leader broker that matches the listener on which metadata request was processed.
                Test:           TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/listener_not_found
=== RUN   TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/leader_not_available
    consumer_group_offsets_test.go:296:
                Error Trace:    /Users/lap60627/Documents/PTO/console/backend/pkg/console/consumer_group_offsets_test.go:296
                Error:          Received unexpected error:
                                failed to list end offsets for topics: LEADER_NOT_AVAILABLE: There is no leader for this topic-partition as we are in the middle of a leadership election.
                Test:           TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/leader_not_available
--- FAIL: TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure (0.03s)
    --- FAIL: TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/listener_not_found (0.02s)
    --- FAIL: TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/leader_not_available (0.02s)
FAIL
FAIL    github.com/redpanda-data/console/backend/pkg/console    1.145s
FAIL

After fix, run test TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure successfully:


go test ./pkg/console -run '^TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure$' -count=1 -timeout=3m -v                           ─╯

=== RUN   TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure
=== RUN   TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/listener_not_found
=== RUN   TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/leader_not_available
--- PASS: TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure (0.04s)
    --- PASS: TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/listener_not_found (0.02s)
    --- PASS: TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure/leader_not_available (0.02s)
PASS
ok      github.com/redpanda-data/console/backend/pkg/console    1.490s

Consumer group lag calculation used to fail the whole overview when ListEndOffsets returned a partial ListOffsets failure.
Continue on partial failures so healthy partitions can still report lag, while affected partitions use the existing partition error field.
Keep total failures fatal.
Copilot AI review requested due to automatic review settings July 23, 2026 08:35

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.

Pull request overview

This PR updates consumer group lag calculation to tolerate partial ListEndOffsets/ListOffsets failures (e.g., LISTENER_NOT_FOUND, LEADER_NOT_AVAILABLE) so the consumer group overview can still be returned for healthy partitions, aligning behavior with issues #2573 and #2327.

Changes:

  • Treat kadm.ShardErrors from ListEndOffsets as non-fatal when some shards succeed, logging a warning and continuing with partial data.
  • Populate per-partition error details when end offsets cannot be fetched, instead of failing the whole request.
  • Add a regression test covering partial ListEndOffsets failures for common broker/partition error scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
backend/pkg/console/consumer_group_offsets.go Allows consumer group lag calculations to proceed when end-offset fetches partially fail, surfacing failures per partition.
backend/pkg/console/consumer_group_offsets_test.go Adds coverage for partial end-offset failures to ensure graceful degradation for consumer group lag results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 208 to +212
ass.Equal(expected, result, "Result should match expected (deleted topic skipped)")
}

func TestGetConsumerGroupOffsets_PartialListEndOffsetsFailure(t *testing.T) {
testCases := []struct {
@ngyngcphu
ngyngcphu force-pushed the fix/consumer-group-partial-offset-errors branch from e735cd7 to 0c70ea6 Compare July 23, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Consumer group overview fails when ListOffsets returns LEADER_NOT_AVAILABLE

2 participants