Skip to content

Commit

Permalink
ux: Fix admin heal display with multiple zones (minio#3893)
Browse files Browse the repository at this point in the history
mc admin heal was showing additional unnecessary entries 
of nodes with empty disks listing when that node does not 
belong to the current pool number. A node only belongs to 
one pool, so remove the extra entries.
  • Loading branch information
vadmeste authored and adfost committed Oct 28, 2022
1 parent 00672fd commit 22d4fa8
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions cmd/admin-heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,25 +350,17 @@ func (s verboseBackgroundHealStatusMessage) String() string {
parity, showTolerance := s.HealInfo.SCParity[s.ToleranceForSC]

offlineEndpoints := getOfflineNodes(s.HealInfo.OfflineEndpoints)

allDisks := getAllDisks(s.HealInfo.Sets)
pools := getPoolsIndexes(allDisks)
setsStatus := generateSetsStatus(allDisks)
serversStatus := generateServersStatus(allDisks)

var poolsTolerance = make(map[int]poolInfo)
var poolsInfo = make(map[int]poolInfo)
for _, pool := range pools {
tolerance := computePoolTolerance(pool, parity, setsStatus, serversStatus)
endpoints := computePoolEndpoints(pool, serversStatus)
poolsTolerance[pool] = poolInfo{tolerance: tolerance, endpoints: endpoints}
}

// Sort endpoints by name
var orderedEndpoints []string
for endpoint := range serversStatus {
orderedEndpoints = append(orderedEndpoints, endpoint)
poolsInfo[pool] = poolInfo{tolerance: tolerance, endpoints: endpoints}
}
sort.Strings(orderedEndpoints)

distributed := len(serversStatus) > 1

Expand All @@ -380,10 +372,17 @@ func (s verboseBackgroundHealStatusMessage) String() string {
fmt.Fprintf(&msg, "==============\n")

sort.Ints(pools)

for _, pool := range pools {
fmt.Fprintf(&msg, "Pool %d:\n", pool+1)

// Sort servers in this pool by name
var orderedEndpoints = make([]string, len(poolsInfo[pool].endpoints))
copy(orderedEndpoints, poolsInfo[pool].endpoints)
sort.Strings(orderedEndpoints)

for _, endpoint := range orderedEndpoints {
// Print offline status if node is offline
_, ok := offlineEndpoints[endpoint]
if ok {
stateText := console.Colorize("NodeFailed", "OFFLINE")
Expand All @@ -394,7 +393,7 @@ func (s verboseBackgroundHealStatusMessage) String() string {
switch {
case showTolerance:
serverHeader := " %s: (Tolerance: %d server(s))\n"
fmt.Fprintf(&msg, fmt.Sprintf(serverHeader, endpoint, poolsTolerance[serverStatus.pool].tolerance))
fmt.Fprintf(&msg, fmt.Sprintf(serverHeader, endpoint, poolsInfo[serverStatus.pool].tolerance))
default:
serverHeader := " %s:\n"
fmt.Fprintf(&msg, fmt.Sprintf(serverHeader, endpoint))
Expand Down Expand Up @@ -436,7 +435,7 @@ func (s verboseBackgroundHealStatusMessage) String() string {
if showTolerance && distributed {
fmt.Fprintf(&msg, "Server Failure Tolerance:\n")
fmt.Fprintf(&msg, "========================\n")
for _, pool := range poolsTolerance {
for _, pool := range poolsInfo {
fmt.Fprintf(&msg, "Pool 1:\n")
fmt.Fprintf(&msg, " Tolerance : %d server(s)\n", pool.tolerance)
fmt.Fprintf(&msg, " Nodes :")
Expand All @@ -447,12 +446,12 @@ func (s verboseBackgroundHealStatusMessage) String() string {
}
}

summry := shortBackgroundHealStatusMessage{HealInfo: s.HealInfo}
summary := shortBackgroundHealStatusMessage{HealInfo: s.HealInfo}

fmt.Fprintf(&msg, "\n")
fmt.Fprintf(&msg, "Summary:\n")
fmt.Fprintf(&msg, "=======\n")
fmt.Fprintf(&msg, summry.String())
fmt.Fprintf(&msg, summary.String())
fmt.Fprintf(&msg, "\n")

return msg.String()
Expand Down

0 comments on commit 22d4fa8

Please sign in to comment.