mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
fix: keep writing previous speedtest result (#15484)
when object speedtest is running keep writing previous speedtest result back to client until we have a new result - this avoids sending back blank entries in between the speedtest when it is running in 'autotune' mode.
This commit is contained in:
parent
102295f58a
commit
5e4213b3be
@ -1272,14 +1272,24 @@ func (a adminAPIHandlers) ObjectSpeedTestHandler(w http.ResponseWriter, r *http.
|
||||
storageClass: storageClass,
|
||||
bucketName: customBucket,
|
||||
})
|
||||
var prevResult madmin.SpeedTestResult
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-keepAliveTicker.C:
|
||||
// Write a blank entry to prevent client from disconnecting
|
||||
if err := enc.Encode(madmin.SpeedTestResult{}); err != nil {
|
||||
return
|
||||
// if previous result is set keep writing the
|
||||
// previous result back to the client
|
||||
if prevResult.Version != "" {
|
||||
if err := enc.Encode(prevResult); err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// first result is not yet obtained, keep writing
|
||||
// empty entry to prevent client from disconnecting.
|
||||
if err := enc.Encode(madmin.SpeedTestResult{}); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
w.(http.Flusher).Flush()
|
||||
case result, ok := <-ch:
|
||||
@ -1289,6 +1299,7 @@ func (a adminAPIHandlers) ObjectSpeedTestHandler(w http.ResponseWriter, r *http.
|
||||
if err := enc.Encode(result); err != nil {
|
||||
return
|
||||
}
|
||||
prevResult = result
|
||||
w.(http.Flusher).Flush()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user