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: Do not print a cryptic msg when scanning a dangling object #5084

Merged
merged 1 commit into from
Nov 21, 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
2 changes: 1 addition & 1 deletion cmd/admin-heal-result-item.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (h hri) getObjectHCCChange() (b, a col, err error) {
}
a, err = getHColCode(surplusShardsAfterHeal, parityShards)
if err != nil {
err = fmt.Errorf("%w: surplusShardsBeforeHeal: %d, parityShards: %d",
err = fmt.Errorf("%w: surplusShardsAfterHeal: %d, parityShards: %d",
err, surplusShardsAfterHeal, parityShards)
}
return
Expand Down
29 changes: 17 additions & 12 deletions cmd/admin-heal-ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (

func getHColCode(surplusShards, parityShards int) (c col, err error) {
if parityShards < 1 || parityShards > 8 || surplusShards > parityShards {
return c, fmt.Errorf("Invalid parity shard count/surplus shard count given")
return c, errors.New("Invalid parity shard count/surplus shard count given")
}
if surplusShards < 0 {
return colGrey, err
Expand All @@ -63,7 +63,7 @@ func getHColCode(surplusShards, parityShards int) (c col, err error) {
return hColOrder[index], err
}
}
return c, fmt.Errorf("cannot get a heal color code")
return c, errors.New("cannot get a heal color code")
}

type uiData struct {
Expand Down Expand Up @@ -207,6 +207,7 @@ func (ui *uiData) printItemsQuietly(s *madmin.HealTaskStatus) (err error) {
var b, a col
for _, item := range s.Items {
h := newHRI(&item)
hrStr := h.getHealResultStr()
switch h.Type {
case madmin.HealItemBucket:
b, a, err = h.getBucketHCCChange()
Expand All @@ -216,10 +217,14 @@ func (ui *uiData) printItemsQuietly(s *madmin.HealTaskStatus) (err error) {
b, a, err = h.getObjectHCCChange()
}
if err != nil {
return err
errMsg := err.Error()
if h.Detail != "" {
errMsg = h.Detail
}
console.PrintC("[ERROR] ** ", hrStr, " **", ": ", errMsg, "\n")
continue
}
printColStr(b, a)
hrStr := h.getHealResultStr()
switch h.Type {
case madmin.HealItemMetadata, madmin.HealItemBucketMetadata:
console.PrintC(fmt.Sprintln("**", hrStr, "**"))
Expand All @@ -244,6 +249,7 @@ func (ui *uiData) printItemsJSON(s *madmin.HealTaskStatus) (err error) {
type healRec struct {
Status string `json:"status"`
Error string `json:"error,omitempty"`
Detail string `json:"detail,omitempty"`
Type string `json:"type"`
Name string `json:"name"`
Before struct {
Expand Down Expand Up @@ -284,6 +290,7 @@ func (ui *uiData) printItemsJSON(s *madmin.HealTaskStatus) (err error) {
if err != nil {
r.Error = err.Error()
}
r.Detail = h.Detail
r.Before.Color = strings.ToLower(string(b))
r.After.Color = strings.ToLower(string(a))
r.Before.Online, r.After.Online = h.GetOnlineCounts()
Expand Down Expand Up @@ -375,7 +382,7 @@ func (ui *uiData) updateUI(s *madmin.HealTaskStatus) (err error) {
return nil
}

func (ui *uiData) UpdateDisplay(s *madmin.HealTaskStatus) (err error) {
func (ui *uiData) UpdateDisplay(s *madmin.HealTaskStatus) {
// Update state
ui.updateDuration(s)
for _, i := range s.Items {
Expand All @@ -385,11 +392,11 @@ func (ui *uiData) UpdateDisplay(s *madmin.HealTaskStatus) (err error) {
// Update display
switch {
case globalJSON:
err = ui.printItemsJSON(s)
ui.printItemsJSON(s)
case globalQuiet:
err = ui.printItemsQuietly(s)
ui.printItemsQuietly(s)
default:
err = ui.updateUI(s)
ui.updateUI(s)
}
return
}
Expand Down Expand Up @@ -426,10 +433,8 @@ func (ui *uiData) DisplayAndFollowHealStatus(aliasedURL string) (res madmin.Heal
console.RewindLines(8)
}
}
err = ui.UpdateDisplay(&res)
if err != nil {
return res, err
}

ui.UpdateDisplay(&res)

if res.Summary == "finished" {
if globalJSON {
Expand Down
Loading