fix: admin heal info output for multiple pools (#3905)
locally setup multiple pools was showing incorrect values where secondary pool was ignored, also fix possible estimate correction if needed.
This commit is contained in:
+19
-21
@@ -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.
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
@@ -216,6 +217,7 @@ func getPoolsIndexes(disks []madmin.Disk) []int {
|
||||
for pool := range m {
|
||||
pools = append(pools, pool)
|
||||
}
|
||||
sort.Ints(pools)
|
||||
return pools
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
@@ -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)
|
||||
@@ -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))
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user