From 24af63da42122950bc9cb34f3a246e5e43b5ef3b Mon Sep 17 00:00:00 2001 From: Shireesh Anjal <355479+anjalshireesh@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:23:34 +0530 Subject: [PATCH] Fix incorrect logic in serverHealthInfo (#3442) It was being assumed that whole response has been received as soon as info.Version is non-empty. This is wrong as the very first response by minio contains the version. So removed the unnecessary for loop that had this check to ensure that the whole report is received properly. --- api/client-admin.go | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/api/client-admin.go b/api/client-admin.go index eaae02422..9064cd5a9 100644 --- a/api/client-admin.go +++ b/api/client-admin.go @@ -383,22 +383,17 @@ func (ac AdminClient) serverHealthInfo(ctx context.Context, deadline time.Durati info := madmin.HealthInfo{} var healthInfo interface{} var version string - var tryCount int - for info.Version == "" && tryCount < 10 { - var resp *http.Response - var err error - resp, version, err = ac.Client.ServerHealthInfo(ctx, madmin.HealthDataTypesList, deadline, "") - if err != nil { - return nil, version, err + var resp *http.Response + var err error + resp, version, err = ac.Client.ServerHealthInfo(ctx, madmin.HealthDataTypesList, deadline, "") + if err != nil { + return nil, version, err + } + decoder := json.NewDecoder(resp.Body) + for { + if err = decoder.Decode(&info); err != nil { + break } - decoder := json.NewDecoder(resp.Body) - for { - if err = decoder.Decode(&info); err != nil { - break - } - } - tryCount++ - time.Sleep(2 * time.Second) } if info.Version == "" { return nil, "", ErrHealthReportFail