From f91cf73d1f0e72150459021729a1f4f25f229203 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Sat, 25 May 2024 22:46:23 -0600 Subject: [PATCH] kadm: use -1 for the commit if a topic is not committed to Previously, if a topic had commits but some partitions in it did not, then Lag would do the CORRECT thing and show -1 for partitions that did not have a commit. What was NOT correct was that if an ENTIRE topic had no commits, then Lag would show the commit as 0. --- pkg/kadm/groups.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/kadm/groups.go b/pkg/kadm/groups.go index 6adca804..de925658 100644 --- a/pkg/kadm/groups.go +++ b/pkg/kadm/groups.go @@ -1588,19 +1588,19 @@ func CalculateGroupLag( tend := endOffsets[t.Topic] for _, p := range t.Partitions { var ( - pcommit OffsetResponse - pend ListedOffset - perr error - ok bool + pcommit = OffsetResponse{Offset: Offset{ + Topic: t.Topic, + Partition: p, + At: -1, + }} + pend ListedOffset + perr error + ok bool ) if tcommit != nil { - if pcommit, ok = tcommit[p]; !ok { - pcommit = OffsetResponse{Offset: Offset{ - Topic: t.Topic, - Partition: p, - At: -1, - }} + if actualpcommit, ok := tcommit[p]; ok { + pcommit = actualpcommit } } if tend == nil {