Skip to content

Commit

Permalink
heal: Simplify bucket healing status
Browse files Browse the repository at this point in the history
Avoid using drive count concept to pick a color for a bucket healing
result. This was straighforward when we were healing a bucket per erasure set
but now it becomes more complex to show a result.

Pick green if everything is okay, yellow if a bucket is missing in a
drive, red for any other drive state (unformatted, offline, ..) and
grey for any weird situation.
  • Loading branch information
Anis Eleuch committed Nov 13, 2024
1 parent 63eb4a4 commit c78c66a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
41 changes: 41 additions & 0 deletions cmd/admin-heal-result-item.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package cmd

import (
"errors"
"fmt"

"github.com/minio/madmin-go/v3"
Expand Down Expand Up @@ -55,6 +56,46 @@ func (h hri) getObjectHCCChange() (b, a col, err error) {
return
}

// getBucketHCCChange - fetches health color code for bucket healing
// this does not return a Grey color since it does not have any meaning
// for a bucket healing. Return green if the bucket is found in a drive,
// yellow for missing, and red for everything else, grey for weird situations
func (h hri) getBucketHCCChange() (b, a col, err error) {
if h.HealResultItem == nil {
return colGrey, colGrey, errors.New("empty result")
}

getColCode := func(drives []madmin.HealDriveInfo) (c col) {
var missing, unavailable int
for i := range drives {
switch drives[i].State {
case madmin.DriveStateOk:
case madmin.DriveStateMissing:
missing++
default:
unavailable++
}
}
if unavailable > 0 {
return colRed
}
if missing > 0 {
return colYellow
}
return colGreen
}

a, b = colGrey, colGrey

if len(h.HealResultItem.Before.Drives) > 0 {
b = getColCode(h.HealResultItem.Before.Drives)
}
if len(h.HealResultItem.After.Drives) > 0 {
a = getColCode(h.HealResultItem.After.Drives)
}
return
}

// getReplicatedFileHCCChange - fetches health color code for metadata
// files that are replicated.
func (h hri) getReplicatedFileHCCChange() (b, a col, err error) {
Expand Down
12 changes: 9 additions & 3 deletions cmd/admin-heal-ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ func (ui *uiData) updateStats(i madmin.HealResultItem) error {
var afterCol col
h := newHRI(&i)
switch h.Type {
case madmin.HealItemMetadata, madmin.HealItemBucket:
case madmin.HealItemBucket:
_, afterCol, err = h.getBucketHCCChange()
case madmin.HealItemMetadata, madmin.HealItemBucketMetadata:
_, afterCol, err = h.getReplicatedFileHCCChange()
default:
_, afterCol, err = h.getObjectHCCChange()
Expand Down Expand Up @@ -206,7 +208,9 @@ func (ui *uiData) printItemsQuietly(s *madmin.HealTaskStatus) (err error) {
for _, item := range s.Items {
h := newHRI(&item)
switch h.Type {
case madmin.HealItemMetadata, madmin.HealItemBucket:
case madmin.HealItemBucket:
b, a, err = h.getBucketHCCChange()
case madmin.HealItemMetadata, madmin.HealItemBucketMetadata:
b, a, err = h.getReplicatedFileHCCChange()
default:
b, a, err = h.getObjectHCCChange()
Expand Down Expand Up @@ -267,7 +271,9 @@ func (ui *uiData) printItemsJSON(s *madmin.HealTaskStatus) (err error) {
var b, a col
var err error
switch h.Type {
case madmin.HealItemMetadata, madmin.HealItemBucket:
case madmin.HealItemBucket:
b, a, err = h.getBucketHCCChange()
case madmin.HealItemMetadata, madmin.HealItemBucketMetadata:
b, a, err = h.getReplicatedFileHCCChange()
default:
if h.Type == madmin.HealItemObject {
Expand Down

0 comments on commit c78c66a

Please sign in to comment.