Skip to content

Commit

Permalink
Merge pull request #1102 from ripienaar/ux_fixes
Browse files Browse the repository at this point in the history
Small UX fixes and prevent a panic
  • Loading branch information
ripienaar authored Jul 26, 2024
2 parents f4ed67c + 2abec0e commit 80dfaa1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cli/stream_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,18 +831,18 @@ func (c *streamCmd) leaderStandDown(_ *fisk.ParseContext) error {
return err
}

if info.Cluster == nil {
if info.Cluster == nil || len(info.Cluster.Replicas) == 0 {
return fmt.Errorf("stream %q is not clustered", stream.Name())
}

leader := info.Cluster.Leader
if leader == "" && !c.force {
return fmt.Errorf("stream has no current leader")
return fmt.Errorf("stream %q has no current leader", stream.Name())
} else if leader == "" {
leader = "<unknown>"
}

log.Printf("Requesting leader step down of %q in a %d peer cluster group", leader, len(info.Cluster.Replicas)+1)
log.Printf("Requesting leader step down of %q for stream %q in a %d peer cluster group", leader, stream.Name(), len(info.Cluster.Replicas)+1)
err = stream.LeaderStepDown()
if err != nil {
return err
Expand All @@ -852,7 +852,7 @@ func (c *streamCmd) leaderStandDown(_ *fisk.ParseContext) error {
start := time.Now()
for range time.NewTicker(500 * time.Millisecond).C {
if ctr == 10 {
return fmt.Errorf("stream did not elect a new leader in time")
return fmt.Errorf("stream %q did not elect a new leader in time", stream.Name())
}
ctr++

Expand All @@ -862,7 +862,7 @@ func (c *streamCmd) leaderStandDown(_ *fisk.ParseContext) error {
continue
}

if info.Cluster.Leader == "" {
if info.Cluster == nil || info.Cluster.Leader == "" {
log.Printf("No leader elected")
continue
}
Expand Down
4 changes: 4 additions & 0 deletions columns/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"math"
"os"
"sort"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -394,6 +395,9 @@ func F(v any) string {
case uint16:
return humanize.Comma(int64(x))
case uint64:
if x >= math.MaxInt64 {
return strconv.FormatUint(x, 10)
}
return humanize.Comma(int64(x))
case int:
return humanize.Comma(int64(x))
Expand Down

0 comments on commit 80dfaa1

Please sign in to comment.