fix: osinfos incomplete in case of warnings (#11505)

The function used for getting host information
(host.SensorsTemperaturesWithContext) returns warnings in some cases.

Returning with error in such cases means we miss out on the other useful
information already fetched (os info).

If the OS info has been succesfully fetched, it should always be
included in the output irrespective of whether the other data (CPU
sensors, users) could be fetched or not.
master
Shireesh Anjal 4 years ago committed by GitHub
parent 93fd248b52
commit 928de04f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      cmd/healthinfo_linux.go

@ -37,7 +37,10 @@ func getLocalOsInfo(ctx context.Context, r *http.Request) madmin.ServerOsInfo {
addr = GetLocalPeer(globalEndpoints) addr = GetLocalPeer(globalEndpoints)
} }
info, err := host.InfoWithContext(ctx) srvrOsInfo := madmin.ServerOsInfo{Addr: addr}
var err error
srvrOsInfo.Info, err = host.InfoWithContext(ctx)
if err != nil { if err != nil {
return madmin.ServerOsInfo{ return madmin.ServerOsInfo{
Addr: addr, Addr: addr,
@ -45,23 +48,18 @@ func getLocalOsInfo(ctx context.Context, r *http.Request) madmin.ServerOsInfo {
} }
} }
sensors, err := host.SensorsTemperaturesWithContext(ctx) srvrOsInfo.Sensors, err = host.SensorsTemperaturesWithContext(ctx)
if err != nil { if err != nil {
return madmin.ServerOsInfo{ // Set error only when it's not of WARNINGS type
Addr: addr, if _, isWarning := err.(*host.Warnings); !isWarning {
Error: fmt.Sprintf("sensors-temp: %v", err), srvrOsInfo.Error = fmt.Sprintf("sensors-temp: %v", err)
} }
} }
// ignore user err, as it cannot be obtained reliably inside containers // ignore user err, as it cannot be obtained reliably inside containers
users, _ := host.UsersWithContext(ctx) srvrOsInfo.Users, _ = host.UsersWithContext(ctx)
return madmin.ServerOsInfo{ return srvrOsInfo
Addr: addr,
Info: info,
Sensors: sensors,
Users: users,
}
} }
func getLocalDiskHwInfo(ctx context.Context, r *http.Request) madmin.ServerDiskHwInfo { func getLocalDiskHwInfo(ctx context.Context, r *http.Request) madmin.ServerDiskHwInfo {

Loading…
Cancel
Save