perf: Only remove generated data when no bucket name specified (#16610)

This commit is contained in:
Anis Elleuch 2023-02-22 06:21:40 +01:00 committed by GitHub
parent fb17f97cf3
commit 6efe4d1df6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1217,6 +1217,7 @@ func (a adminAPIHandlers) ObjectSpeedTestHandler(w http.ResponseWriter, r *http.
storageClass := strings.TrimSpace(r.Form.Get(peerRESTStorageClass)) storageClass := strings.TrimSpace(r.Form.Get(peerRESTStorageClass))
customBucket := strings.TrimSpace(r.Form.Get(peerRESTBucket)) customBucket := strings.TrimSpace(r.Form.Get(peerRESTBucket))
autotune := r.Form.Get("autotune") == "true" autotune := r.Form.Get("autotune") == "true"
noClear := r.Form.Get("noclear") == "true"
size, err := strconv.Atoi(sizeStr) size, err := strconv.Atoi(sizeStr)
if err != nil { if err != nil {
@ -1258,14 +1259,16 @@ func (a adminAPIHandlers) ObjectSpeedTestHandler(w http.ResponseWriter, r *http.
return return
} }
if !bucketExists { if !noClear && !bucketExists {
defer deleteObjectPerfBucket(objectAPI) defer deleteObjectPerfBucket(objectAPI)
} }
} }
if !noClear {
defer objectAPI.DeleteObject(ctx, customBucket, speedTest+SlashSeparator, ObjectOptions{ defer objectAPI.DeleteObject(ctx, customBucket, speedTest+SlashSeparator, ObjectOptions{
DeletePrefix: true, DeletePrefix: true,
}) })
}
// Freeze all incoming S3 API calls before running speedtest. // Freeze all incoming S3 API calls before running speedtest.
globalNotificationSys.ServiceFreeze(ctx, true) globalNotificationSys.ServiceFreeze(ctx, true)