Skip to content

Commit 24af63d

Browse files
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.
1 parent 52c77fd commit 24af63d

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

api/client-admin.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -383,22 +383,17 @@ func (ac AdminClient) serverHealthInfo(ctx context.Context, deadline time.Durati
383383
info := madmin.HealthInfo{}
384384
var healthInfo interface{}
385385
var version string
386-
var tryCount int
387-
for info.Version == "" && tryCount < 10 {
388-
var resp *http.Response
389-
var err error
390-
resp, version, err = ac.Client.ServerHealthInfo(ctx, madmin.HealthDataTypesList, deadline, "")
391-
if err != nil {
392-
return nil, version, err
393-
}
394-
decoder := json.NewDecoder(resp.Body)
395-
for {
396-
if err = decoder.Decode(&info); err != nil {
397-
break
398-
}
386+
var resp *http.Response
387+
var err error
388+
resp, version, err = ac.Client.ServerHealthInfo(ctx, madmin.HealthDataTypesList, deadline, "")
389+
if err != nil {
390+
return nil, version, err
391+
}
392+
decoder := json.NewDecoder(resp.Body)
393+
for {
394+
if err = decoder.Decode(&info); err != nil {
395+
break
399396
}
400-
tryCount++
401-
time.Sleep(2 * time.Second)
402397
}
403398
if info.Version == "" {
404399
return nil, "", ErrHealthReportFail

0 commit comments

Comments
 (0)