Skip to content

Commit

Permalink
rpk cluster logdirs: fix error exit, print by size descending
Browse files Browse the repository at this point in the history
* if listing topics failed, we would panic
* for printing by size, we should print descending similar to other CLI
  tools
  • Loading branch information
twmb committed Jul 6, 2023
1 parent ff83af1 commit 330566e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/go/rpk/pkg/cli/cluster/logdirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,14 @@ where revision is a Redpanda internal concept.
if len(topics) > 0 {
listed, err := adm.ListTopics(context.Background(), topics...)
out.MaybeDie(err, "unable to describe topics: %v", err)
var exit bool
listed.EachError(func(d kadm.TopicDetail) {
fmt.Fprintf(os.Stderr, "unable to discover the partitions on topic %q: %v\n", d.Topic, d.Err)
exit = true
})
if exit {
os.Exit(1)
}
s = listed.TopicsSet()
}

Expand Down Expand Up @@ -190,7 +195,7 @@ where revision is a Redpanda internal concept.
// what we have already ordered and aggregated.
if sortBySize {
sort.SliceStable(rows, func(i, j int) bool {
return rows[i].Size < rows[j].Size
return rows[i].Size >= rows[j].Size
})
}

Expand Down

0 comments on commit 330566e

Please sign in to comment.