Skip to content

Commit

Permalink
heal: Show healed objects count even if healing start time is unknown (
Browse files Browse the repository at this point in the history
…#3896)

mc summary should still show some information when some disks report
healing in progress but without started time.
  • Loading branch information
vadmeste committed Dec 16, 2021
1 parent 68a9e3f commit 7bd5c34
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmd/admin-heal.go
Expand Up @@ -536,7 +536,7 @@ func (s shortBackgroundHealStatusMessage) String() string {
}
}

if startedAt.IsZero() {
if startedAt.IsZero() && itemsHealed == 0 {
healPrettyMsg += "No ongoing active healing."
return healPrettyMsg
}
Expand All @@ -553,11 +553,13 @@ func (s shortBackgroundHealStatusMessage) String() string {
healPrettyMsg += fmt.Sprintf("Objects Healed: %s, %s\n", humanize.Comma(int64(itemsHealed)), humanize.Bytes(bytesHealed))
}

bytesHealedPerSec := float64(uint64(time.Second)*bytesHealed) / float64(accumulatedElapsedTime)
itemsHealedPerSec := float64(uint64(time.Second)*itemsHealed) / float64(accumulatedElapsedTime)
healPrettyMsg += fmt.Sprintf("Heal rate: %d obj/s, %s/s\n", int64(itemsHealedPerSec), humanize.IBytes(uint64(bytesHealedPerSec)))
if accumulatedElapsedTime > 0 {
bytesHealedPerSec := float64(uint64(time.Second)*bytesHealed) / float64(accumulatedElapsedTime)
itemsHealedPerSec := float64(uint64(time.Second)*itemsHealed) / float64(accumulatedElapsedTime)
healPrettyMsg += fmt.Sprintf("Heal rate: %d obj/s, %s/s\n", int64(itemsHealedPerSec), humanize.IBytes(uint64(bytesHealedPerSec)))
}

if totalItems > 0 && totalBytes > 0 {
if totalItems > 0 && totalBytes > 0 && !startedAt.IsZero() {
// Estimation completion
avgTimePerObject := float64(accumulatedElapsedTime) / float64(itemsHealed)
estimatedDuration := time.Duration(avgTimePerObject * float64(totalItems))
Expand Down

0 comments on commit 7bd5c34

Please sign in to comment.