Skip to content

Commit

Permalink
rpk group offset-delete: fix two bugs
Browse files Browse the repository at this point in the history
* We should only request metadata for empty topics if we actually have
  empty topics. Requesting metadata with no empty topics requests
  metadata for the entire cluster, which results in offset-delete for
  all topics.
* For parsing topic partition args, we need to `make` with 0 length.
  Accidentally using the capacity as length results in issuing metadata
  requests with empty topic names (which cropped up another bug in kadm,
  which will be fixed by a dep bump before the next release)
  • Loading branch information
twmb committed Jul 6, 2023
1 parent 330566e commit 726508d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/go/rpk/pkg/cli/group/offset_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ topic_b 0

// For -topic options that didn't include partitions, perform a
// lookup for them using a metadata request
mdResp, err := adm.Metadata(context.Background(), topicsSet.EmptyTopics()...)
out.MaybeDie(err, "unable to make metadata request: %v", err)
topicsSet.Merge(mdResp.Topics.TopicsSet())
if empty := topicsSet.EmptyTopics(); len(empty) > 0 {
mdResp, err := adm.Metadata(context.Background(), empty...)
out.MaybeDie(err, "unable to make metadata request: %v", err)
topicsSet.Merge(mdResp.Topics.TopicsSet())
}

responses, err := adm.DeleteOffsets(context.Background(), args[0], topicsSet)
out.MaybeDieErr(err)
Expand All @@ -100,7 +102,7 @@ topic_b 0
func parseTopicPartitionsArgs(list []string) (kadm.TopicsSet, error) {
parsed, err := out.ParseTopicPartitions(list)
if err == nil {
topicsList := make(kadm.TopicsList, len(parsed))
topicsList := make(kadm.TopicsList, 0, len(parsed))
for topic, partitions := range parsed {
topicsList = append(topicsList, kadm.TopicPartitions{Topic: topic, Partitions: partitions})
}
Expand Down

0 comments on commit 726508d

Please sign in to comment.