Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heal: Simplify bucket healing status #5079

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading