mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
reject speedtest when there isn't enough disk space available (#14402)
small setups do not return appropriate errors when speedtest cannot run on small tiny setups, allow the tests to fail appropriately more pro-actively. many users bring toy setups, this PR simply returns an error in such situations.
This commit is contained in:
parent
3934700a08
commit
c08540c7b7
@ -984,6 +984,31 @@ func (a adminAPIHandlers) ObjectSpeedtestHandler(w http.ResponseWriter, r *http.
|
|||||||
duration = time.Second * 10
|
duration = time.Second * 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignores any errors here.
|
||||||
|
storageInfo, _ := objectAPI.StorageInfo(ctx)
|
||||||
|
capacityNeeded := uint64(concurrent * size)
|
||||||
|
capacity := uint64(GetTotalUsableCapacityFree(storageInfo.Disks, storageInfo))
|
||||||
|
|
||||||
|
if capacity < capacityNeeded {
|
||||||
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, AdminError{
|
||||||
|
Code: "XMinioSpeedtestInsufficientCapacity",
|
||||||
|
Message: fmt.Sprintf("not enough usable space available to perform speedtest - expected %s, got %s",
|
||||||
|
humanize.IBytes(capacityNeeded), humanize.IBytes(capacity)),
|
||||||
|
StatusCode: http.StatusInsufficientStorage,
|
||||||
|
}), r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify if we can employ autotune without running out of capacity,
|
||||||
|
// if we do run out of capacity, make sure to turn-off autotuning
|
||||||
|
// in such situations.
|
||||||
|
newConcurrent := concurrent + (concurrent+1)/2
|
||||||
|
autoTunedCapacityNeeded := uint64(newConcurrent * size)
|
||||||
|
if autotune && capacity < autoTunedCapacityNeeded {
|
||||||
|
// Turn-off auto-tuning if next possible concurrency would reach beyond disk capacity.
|
||||||
|
autotune = false
|
||||||
|
}
|
||||||
|
|
||||||
deleteBucket := func() {
|
deleteBucket := func() {
|
||||||
objectAPI.DeleteBucket(context.Background(), pathJoin(minioMetaBucket, "speedtest"), DeleteBucketOptions{
|
objectAPI.DeleteBucket(context.Background(), pathJoin(minioMetaBucket, "speedtest"), DeleteBucketOptions{
|
||||||
Force: true,
|
Force: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user