From cf209db6b91a6638a9b32b7e9393b84ef27caaad Mon Sep 17 00:00:00 2001 From: Girish Kumar <45126881+0xgirish@users.noreply.github.com> Date: Sat, 27 Apr 2024 02:55:57 +0530 Subject: [PATCH 1/2] fix: client.Lag doesn't calculate lag for all consumergroups with client.Lag(ctx) Signed-off-by: Girish Kumar <45126881+0xgirish@users.noreply.github.com> --- pkg/kadm/groups.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/kadm/groups.go b/pkg/kadm/groups.go index 6adca804..477a9b63 100644 --- a/pkg/kadm/groups.go +++ b/pkg/kadm/groups.go @@ -1460,7 +1460,12 @@ func (cl *Client) Lag(ctx context.Context, groups ...string) (DescribedGroupLags } if g.Err != nil { delete(set, g.Group) + continue } + + // if no groups were specified for lag calculation, we will calculate lag for all groups + // adding groups to the set again. + set[g.Group] = struct{}{} } if len(set) == 0 { return lags, nil From 823ff5bf1b40e0b1662ccc93e4fdbf7617cb5492 Mon Sep 17 00:00:00 2001 From: Girish Kumar <45126881+0xgirish@users.noreply.github.com> Date: Sat, 4 May 2024 10:36:22 +0530 Subject: [PATCH 2/2] Update groups.go --- pkg/kadm/groups.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/kadm/groups.go b/pkg/kadm/groups.go index 477a9b63..2716450f 100644 --- a/pkg/kadm/groups.go +++ b/pkg/kadm/groups.go @@ -1463,8 +1463,9 @@ func (cl *Client) Lag(ctx context.Context, groups ...string) (DescribedGroupLags continue } - // if no groups were specified for lag calculation, we will calculate lag for all groups - // adding groups to the set again. + // If the input set of groups is empty, DescribeGroups returns all groups. + // We add to `set` here so that the Lag function itself can calculate + // lag for all groups. set[g.Group] = struct{}{} } if len(set) == 0 {