Skip to content

Commit

Permalink
heal: Show scheduled next healing
Browse files Browse the repository at this point in the history
mc admin heal alias command will show the next healing time.

Also show 'Never completed' when the server returns zero last healing activity
  • Loading branch information
vadmeste committed Mar 12, 2020
1 parent 1092f69 commit d080181
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
20 changes: 17 additions & 3 deletions cmd/admin-heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,24 @@ type backgroundHealStatusMessage struct {

// String colorized to show background heal status message.
func (s backgroundHealStatusMessage) String() string {
dot := console.Colorize("Dot", " ● ")

healPrettyMsg := console.Colorize("HealBackgroundTitle", "Background healing status:\n")
healPrettyMsg += fmt.Sprintf(" Total items scanned: %s\n",
healPrettyMsg += dot + fmt.Sprintf("%s item(s) scanned in total\n",
console.Colorize("HealBackground", s.HealInfo.ScannedItemsCount))
healPrettyMsg += fmt.Sprintf(" Last background heal check: %s\n",
console.Colorize("HealBackground", timeDurationToHumanizedDuration(time.Since(s.HealInfo.LastHealActivity)).String()+" ago"))

lastHealingTime := dot + "Never executed"
if !s.HealInfo.LastHealActivity.IsZero() {
lastHealingTime = dot + "Completed " + timeDurationToHumanizedDuration(time.Since(s.HealInfo.LastHealActivity)).StringShort() + " ago"
}
healPrettyMsg += console.Colorize("HealBackground", lastHealingTime) + "\n"

now := time.Now()
if !s.HealInfo.NextHealRound.IsZero() && s.HealInfo.NextHealRound.After(now) {
nextHealingRound := timeDurationToHumanizedDuration(s.HealInfo.NextHealRound.Sub(now)).StringShort()
healPrettyMsg += dot + fmt.Sprintf("Next scheduled in %s\n", console.Colorize("HealBackground", nextHealingRound))
}

return healPrettyMsg
}

Expand Down Expand Up @@ -185,6 +198,7 @@ func mainAdminHeal(ctx *cli.Context) error {
aliasedURL := args.Get(0)

console.SetColor("Heal", color.New(color.FgGreen, color.Bold))
console.SetColor("Dot", color.New(color.FgGreen, color.Bold))
console.SetColor("HealBackgroundTitle", color.New(color.FgGreen, color.Bold))
console.SetColor("HealBackground", color.New(color.Bold))
console.SetColor("HealUpdateUI", color.New(color.FgYellow, color.Bold))
Expand Down
13 changes: 9 additions & 4 deletions cmd/humanized-duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ type humanizedDuration struct {
// StringShort() humanizes humanizedDuration to human readable short format.
// This does not print at seconds.
func (r humanizedDuration) StringShort() string {
if r.Days == 0 && r.Hours == 0 {
switch {
case r.Days == 0 && r.Hours == 0 && r.Minutes == 0:
return fmt.Sprintf("%d seconds", r.Seconds)
case r.Days == 0 && r.Hours == 0:
return fmt.Sprintf("%d minutes", r.Minutes)
}
if r.Days == 0 {
case r.Days == 0:
return fmt.Sprintf("%d hours %d minutes", r.Hours, r.Minutes)
case r.Days <= 2:
return fmt.Sprintf("%d days, %d hours", r.Days, r.Hours)
default:
return fmt.Sprintf("%d days", r.Days)
}
return fmt.Sprintf("%d days %d hours %d minutes", r.Days, r.Hours, r.Minutes)
}

// String() humanizes humanizedDuration to human readable,
Expand Down
6 changes: 6 additions & 0 deletions docs/minio-admin-complete-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,12 @@ mc admin heal -r myminio/mybucket
mc admin heal -r myminio/mybucket/myobjectprefix
```

*Example: Show the status of the self-healing process in a MinIO cluster.*

```
mc admin heal myminio/
```

<a name="profile"></a>
### Command `profile` - generate profile data for debugging purposes

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/mattn/go-isatty v0.0.7
github.com/mattn/go-runewidth v0.0.5 // indirect
github.com/minio/cli v1.22.0
github.com/minio/minio v0.0.0-20200306033404-a1c7c9ea73d7
github.com/minio/minio v0.0.0-20200312144740-ed4bd20a7cfc
github.com/minio/minio-go/v6 v6.0.50-0.20200306231101-b882ba63d570
github.com/minio/sha256-simd v0.1.1
github.com/mitchellh/go-homedir v1.1.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
github.com/klauspost/compress v1.9.4/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.10.1 h1:a/QY0o9S6wCi0XhxaMX/QmusicNUqCqFugR6WKPOSoQ=
github.com/klauspost/compress v1.10.1/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/cpuid v1.2.2 h1:1xAgYebNnsb9LKCdLOvFWtAxGU/33mjJtyOVbmUa0Us=
github.com/klauspost/cpuid v1.2.2/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM=
Expand Down Expand Up @@ -249,11 +251,9 @@ github.com/minio/highwayhash v1.0.0 h1:iMSDhgUILCr0TNm8LWlSjF8N0ZIj2qbO8WHp6Q/J2
github.com/minio/highwayhash v1.0.0/go.mod h1:xQboMTeM9nY9v/LlAOxFctujiv5+Aq2hR5dxBpaMbdc=
github.com/minio/lsync v1.0.1 h1:AVvILxA976xc27hstd1oR+X9PQG0sPSom1MNb1ImfUs=
github.com/minio/lsync v1.0.1/go.mod h1:tCFzfo0dlvdGl70IT4IAK/5Wtgb0/BrTmo/jE8pArKA=
github.com/minio/minio v0.0.0-20200306033404-a1c7c9ea73d7 h1:aO9WwlJKc0SFWNCOXHULHnz0QPAgQITDnj/bOFVBLR0=
github.com/minio/minio v0.0.0-20200306033404-a1c7c9ea73d7/go.mod h1:SxU0r96Z6zUj3lQAuPtyokbC0JEbqZ4x5RVcvl86TN0=
github.com/minio/minio v0.0.0-20200312144740-ed4bd20a7cfc h1:JvRNAEmHghf0mPluxNLnleD2LZz+fyew0ddf6Xt5gD8=
github.com/minio/minio v0.0.0-20200312144740-ed4bd20a7cfc/go.mod h1:QbCnTGb/blyNjrkyxB9ecKxtuWWUdcHShqED1bItwa0=
github.com/minio/minio-go/v6 v6.0.45/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/minio-go/v6 v6.0.49-0.20200218155844-112c09f43c78 h1:rGiqpjReCifELAwekJF3istDiHtW3jQYWaR/tbtRfAU=
github.com/minio/minio-go/v6 v6.0.49-0.20200218155844-112c09f43c78/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/minio-go/v6 v6.0.50-0.20200306231101-b882ba63d570 h1:GLTZoRC6rhCTucnkJAQ63LhMU2S4CM71MRc9gfX7ohE=
github.com/minio/minio-go/v6 v6.0.50-0.20200306231101-b882ba63d570/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
github.com/minio/parquet-go v0.0.0-20200125064549-a1e49702e174 h1:WYFHZIJ5LTWd4C3CW26jguaBLLDdX7l1/Xa3QSKGkIc=
Expand Down

0 comments on commit d080181

Please sign in to comment.