Skip to content

Commit

Permalink
fix: divde by zero for decom status (#4908)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuker committed Apr 29, 2024
1 parent 4a3f589 commit 5b7b222
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/admin-decom-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ func mainAdminDecommissionStatus(ctx *cli.Context) error {
idx++
totalSize := uint64(pool.Decommission.TotalSize)
usedCurrent := uint64(pool.Decommission.TotalSize - pool.Decommission.CurrentSize)
capacity := fmt.Sprintf("%.1f%% (total: %s)", 100*float64(usedCurrent)/float64(totalSize), humanize.IBytes(totalSize))
var capacity string
if totalSize == 0 {
capacity = "0% (total: 0B)"
} else {
capacity = fmt.Sprintf("%.1f%% (total: %s)", 100*float64(usedCurrent)/float64(totalSize), humanize.IBytes(totalSize))
}
status := "Active"
if pool.Decommission != nil {
if pool.Decommission.Complete {
Expand Down

0 comments on commit 5b7b222

Please sign in to comment.