Skip to content

Commit

Permalink
heal: Do not print a cryptic msg when scanning a dangling object (#5084)
Browse files Browse the repository at this point in the history
Healing in server side will list with quorum 1, so it will pick stale
objects as well. This is currently not rendered well in mc that shows
this cryptic message:
	Invalid parity shard count/surplus shard count given

Print the text sent by the server instead.
  • Loading branch information
vadmeste authored Nov 21, 2024
1 parent 35cb4b8 commit 1681e44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
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

0 comments on commit 1681e44

Please sign in to comment.