fix: health report incompatibility with old minio (#3751)
When the subnet health command from current mc is used with the MinIO versions before the latest health data structure changes (v2) were introduced, the generated report doesn't contain the cluster information (minio -> info). This is because these old versions of minio don't return this information in the output of the `healthinfo` api. Fixed this by explicitly pulling the server info separately when we detect that the health schema version is not v2.
This commit is contained in:
@@ -486,8 +486,8 @@ func fetchServerHealthInfo(ctx *cli.Context, client *madmin.AdminClient) (interf
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
switch version {
|
||||
case madmin.HealthInfoVersion0:
|
||||
info := madmin.HealthInfoV0{}
|
||||
for {
|
||||
var info madmin.HealthInfoV0
|
||||
if err = decoder.Decode(&info); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
err = nil
|
||||
@@ -497,11 +497,23 @@ func fetchServerHealthInfo(ctx *cli.Context, client *madmin.AdminClient) (interf
|
||||
}
|
||||
|
||||
progressV0(info)
|
||||
healthInfo = MapHealthInfoToV1(info, nil)
|
||||
}
|
||||
|
||||
// Old minio versions don't return the MinIO info in
|
||||
// response of the healthinfo api. So fetch it separately
|
||||
minioInfo, err := client.ServerInfo(globalContext)
|
||||
if err != nil {
|
||||
info.Minio.Error = err.Error()
|
||||
} else {
|
||||
info.Minio.Info = minioInfo
|
||||
}
|
||||
|
||||
healthInfo = MapHealthInfoToV1(info, nil)
|
||||
version = madmin.HealthInfoVersion1
|
||||
|
||||
case madmin.HealthInfoVersion:
|
||||
info := madmin.HealthInfo{}
|
||||
for {
|
||||
var info madmin.HealthInfo
|
||||
if err = decoder.Decode(&info); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
err = nil
|
||||
@@ -511,8 +523,8 @@ func fetchServerHealthInfo(ctx *cli.Context, client *madmin.AdminClient) (interf
|
||||
}
|
||||
|
||||
progress(info)
|
||||
healthInfo = info
|
||||
}
|
||||
healthInfo = info
|
||||
}
|
||||
|
||||
// In case any of the spinners have not stopped yet (can happen in some
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ func (ch ClusterHealthV1) GetTimestamp() time.Time {
|
||||
}
|
||||
|
||||
// MapHealthInfoToV1 - maps the health info returned by minio server to V1 format
|
||||
func MapHealthInfoToV1(healthInfo madmin.HealthInfoV0, err error) HealthReportInfo {
|
||||
func MapHealthInfoToV1(healthInfo madmin.HealthInfoV0, err error) ClusterHealthV1 {
|
||||
ch := ClusterHealthV1{}
|
||||
ch.TimeStamp = healthInfo.TimeStamp
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user