Skip to content

Commit

Permalink
fix: admin heal info output for multiple pools (minio#3905)
Browse files Browse the repository at this point in the history
locally setup multiple pools was showing incorrect
values where secondary pool was ignored, also fix
possible estimate correction if needed.
  • Loading branch information
harshavardhana authored Dec 29, 2021
1 parent f06a098 commit 05c3ae8
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions cmd/admin-heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ FLAGS:
EXAMPLES:
1. Monitor healing status on a running server at alias 'myminio':
{{.Prompt}} {{.HelpName}} myminio/
Objects Healed: 7/27 (25.9%), 31 MB/110 MB (0%)
Heal rate: 3 obj/s, 10 MB/s
Estimated Completion: 11 seconds
...
...
Summary:
=======
No ongoing active healing.
`,
}

Expand Down Expand Up @@ -150,13 +152,12 @@ type healingStatus struct {

// Estimation of when the healing will finish
func (h healingStatus) ETA() time.Time {
if h.started.IsZero() {
return time.Time{}
if !h.started.IsZero() && h.totalObjects > h.totalHealed {
objScanSpeed := float64(time.Now().UTC().Sub(h.started)) / float64(h.totalHealed)
remainingDuration := float64(h.totalObjects-h.totalHealed) * objScanSpeed
return time.Now().UTC().Add(time.Duration(remainingDuration))
}

objScanSpeed := float64(time.Since(h.started)) / float64(h.totalHealed)
remainingDuration := float64(h.totalObjects-h.totalHealed) * objScanSpeed
return time.Now().Add(time.Duration(remainingDuration))
return time.Time{}
}

type poolInfo struct {
Expand Down Expand Up @@ -216,6 +217,7 @@ func getPoolsIndexes(disks []madmin.Disk) []int {
for pool := range m {
pools = append(pools, pool)
}
sort.Ints(pools)
return pools
}

Expand Down Expand Up @@ -252,7 +254,7 @@ func generateServersStatus(disks []madmin.Disk) map[string]serverInfo {
}
endpoint := u.Host
if endpoint == "" {
endpoint = "localhost"
endpoint = "local-pool" + humanize.Ordinal(d.PoolIndex+1)
}
serverSt, ok := m[endpoint]
if !ok {
Expand Down Expand Up @@ -348,7 +350,6 @@ func (s verboseBackgroundHealStatusMessage) String() string {
var msg strings.Builder

parity, showTolerance := s.HealInfo.SCParity[s.ToleranceForSC]

offlineEndpoints := getOfflineNodes(s.HealInfo.OfflineEndpoints)
allDisks := getAllDisks(s.HealInfo.Sets)
pools := getPoolsIndexes(allDisks)
Expand All @@ -371,10 +372,8 @@ func (s verboseBackgroundHealStatusMessage) String() string {
fmt.Fprintf(&msg, "Server%s status:\n", plural)
fmt.Fprintf(&msg, "==============\n")

sort.Ints(pools)

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

// Sort servers in this pool by name
var orderedEndpoints = make([]string, len(poolsInfo[pool].endpoints))
Expand Down Expand Up @@ -416,7 +415,7 @@ func (s verboseBackgroundHealStatusMessage) String() string {
if d.healing {
estimationText := "Calculating..."
if eta := setsStatus[d.set].healingStatus.ETA(); !eta.IsZero() {
estimationText = humanize.RelTime(time.Now(), eta, "", "")
estimationText = humanize.RelTime(time.Now().UTC(), eta, "", "")
}
fmt.Fprintf(&msg, " |__ Estimated: %s\n", estimationText)
}
Expand All @@ -430,13 +429,12 @@ func (s verboseBackgroundHealStatusMessage) String() string {
}
}

fmt.Fprintf(&msg, "\n")

if showTolerance && distributed {
if showTolerance {
fmt.Fprintf(&msg, "\n")
fmt.Fprintf(&msg, "Server Failure Tolerance:\n")
fmt.Fprintf(&msg, "========================\n")
for _, pool := range poolsInfo {
fmt.Fprintf(&msg, "Pool 1:\n")
for i, pool := range poolsInfo {
fmt.Fprintf(&msg, "Pool %s:\n", humanize.Ordinal(i+1))
fmt.Fprintf(&msg, " Tolerance : %d server(s)\n", pool.tolerance)
fmt.Fprintf(&msg, " Nodes :")
for _, endpoint := range pool.endpoints {
Expand Down Expand Up @@ -537,7 +535,7 @@ func (s shortBackgroundHealStatusMessage) String() string {
}

if startedAt.IsZero() && itemsHealed == 0 {
healPrettyMsg += "No ongoing active healing."
healPrettyMsg += "No active healing in progress."
return healPrettyMsg
}

Expand Down

0 comments on commit 05c3ae8

Please sign in to comment.