diff --git a/cmd/admin-heal-result-item.go b/cmd/admin-heal-result-item.go index dcdc9a6ac0..2cca316630 100644 --- a/cmd/admin-heal-result-item.go +++ b/cmd/admin-heal-result-item.go @@ -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 diff --git a/cmd/admin-heal-ui.go b/cmd/admin-heal-ui.go index f0a2ea96f2..798d4be01c 100644 --- a/cmd/admin-heal-ui.go +++ b/cmd/admin-heal-ui.go @@ -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 @@ -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 { @@ -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() @@ -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, "**")) @@ -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 { @@ -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() @@ -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 { @@ -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 } @@ -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 {