health-info: Add tags to errors (#11412)

We use multiple libraries in health info, but the returned error does
not indicate exactly what library call is failing, hence adding named
tags to returned errors whenever applicable.
This commit is contained in:
Anis Elleuch
2021-02-05 21:37:15 +01:00
committed by GitHub
parent 1887c25279
commit c7eacba41c
2 changed files with 44 additions and 45 deletions
+8 -7
View File
@@ -21,6 +21,7 @@ package cmd
import (
"context"
"fmt"
"net/http"
"strings"
"syscall"
@@ -41,7 +42,7 @@ func getLocalOsInfo(ctx context.Context, r *http.Request) madmin.ServerOsInfo {
if err != nil {
return madmin.ServerOsInfo{
Addr: addr,
Error: err.Error(),
Error: fmt.Sprintf("info: %v", err),
}
}
@@ -49,7 +50,7 @@ func getLocalOsInfo(ctx context.Context, r *http.Request) madmin.ServerOsInfo {
if err != nil {
return madmin.ServerOsInfo{
Addr: addr,
Error: err.Error(),
Error: fmt.Sprintf("sensors-temp: %v", err),
}
}
@@ -74,7 +75,7 @@ func getLocalDiskHwInfo(ctx context.Context, r *http.Request) madmin.ServerDiskH
if err != nil {
return madmin.ServerDiskHwInfo{
Addr: addr,
Error: err.Error(),
Error: fmt.Sprintf("partitions: %v", err),
}
}
@@ -99,11 +100,11 @@ func getLocalDiskHwInfo(ctx context.Context, r *http.Request) madmin.ServerDiskH
smartInfo, err := smart.GetInfo(device)
if err != nil {
if syscall.EACCES == err {
smartInfo.Error = err.Error()
smartInfo.Error = fmt.Sprintf("smart: %v", err)
} else {
return madmin.ServerDiskHwInfo{
Addr: addr,
Error: err.Error(),
Error: fmt.Sprintf("smart: %v", err),
}
}
}
@@ -122,7 +123,7 @@ func getLocalDiskHwInfo(ctx context.Context, r *http.Request) madmin.ServerDiskH
if err != nil {
return madmin.ServerDiskHwInfo{
Addr: addr,
Error: err.Error(),
Error: fmt.Sprintf("iocounters: %v", err),
}
}
usages := []*diskhw.UsageStat{}
@@ -131,7 +132,7 @@ func getLocalDiskHwInfo(ctx context.Context, r *http.Request) madmin.ServerDiskH
if err != nil {
return madmin.ServerDiskHwInfo{
Addr: addr,
Error: err.Error(),
Error: fmt.Sprintf("usage: %v", err),
}
}
usages = append(usages, usage)