Repository: minio/minio (language: go)

Issue:
MinIO speed test fail on the very first run
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
MinIO speedtest is running/working on the first/initial run.

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
MinIO speedtest will fail on the very first run with the following error:
```
Error: Bucket not found: .minio.sys/speedtest (cmd.BucketNotFound)
       4: cmd/peer-rest-server.go:1211:cmd.selfSpeedtest.func2.2()
       3: sync/once.go:68:sync.(*Once).doSlow()
       2: sync/once.go:59:sync.(*Once).Do()
       1: cmd/peer-rest-server.go:1209:cmd.selfSpeedtest.func2()
```
## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
<!--- and make sure you have followed https://github.com/minio/minio/tree/release/docs/debugging to capture relevant logs -->

1. Run MinIO with below version
2. After creating a MinIO cluster with this version run directly a speedtest

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used (`minio --version`):
``quay.io/minio/minio:RELEASE.2022-01-27T03-53-02Z``
* Server setup and configuration:
Docker container setup:
``server --address 0.0.0.0:9000 --console-address ":9001" https://minio{1...2}/export{1...4}"``
* Operating System and version (`uname -a`):
``Linux minio1 3.10.0-1160.49.1.el7.x86_64 minio/minio#1 SMP Tue Nov 9 16:09:48 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux``


Discussion / hints:
I am not able to reproduce. What about `mc admin info <alias>` ?
> I am not able to reproduce. What about `mc admin info <alias>` ?

I think it's a fresh setup issue @vadmeste since it expects a bucket present.

Fix patch:
diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go
index 8ba0a8c5ac273..1a77cd484dfd9 100644
--- a/cmd/admin-handlers.go
+++ b/cmd/admin-handlers.go
@@ -978,8 +978,7 @@ func (a adminAPIHandlers) SpeedtestHandler(w http.ResponseWriter, r *http.Reques
 	}
 
 	deleteBucket := func() {
-		loc := pathJoin(minioMetaSpeedTestBucket, minioMetaSpeedTestBucketPrefix)
-		objectAPI.DeleteBucket(context.Background(), loc, DeleteBucketOptions{
+		objectAPI.DeleteBucket(context.Background(), pathJoin(minioMetaBucket, "speedtest"), DeleteBucketOptions{
 			Force:      true,
 			NoRecreate: true,
 		})
diff --git a/cmd/object-api-utils.go b/cmd/object-api-utils.go
index 8d6642581ab6e..fa90d1cd2d45d 100644
--- a/cmd/object-api-utils.go
+++ b/cmd/object-api-utils.go
@@ -61,10 +61,7 @@ const (
 	// MinIO tmp meta prefix.
 	minioMetaTmpBucket = minioMetaBucket + "/tmp"
 	// MinIO tmp meta prefix for deleted objects.
-	minioMetaTmpDeletedBucket      = minioMetaTmpBucket + "/.trash"
-	minioMetaSpeedTestBucket       = minioMetaBucket + "/speedtest"
-	minioMetaSpeedTestBucketPrefix = "objects/"
-
+	minioMetaTmpDeletedBucket = minioMetaTmpBucket + "/.trash"
 	// DNS separator (period), used for bucket name validation.
 	dnsDelimiter = "."
 	// On compressed files bigger than this;
diff --git a/cmd/peer-rest-server.go b/cmd/peer-rest-server.go
index 499341b19903d..e773c8bfb1849 100644
--- a/cmd/peer-rest-server.go
+++ b/cmd/peer-rest-server.go
@@ -1168,7 +1168,6 @@ func selfSpeedtest(ctx context.Context, size, concurrent int, duration time.Dura
 	var totalBytesWritten uint64
 	var totalBytesRead uint64
 
-	bucket := minioMetaSpeedTestBucket
 	objCountPerThread := make([]uint64, concurrent)
 	uploadsCtx, uploadsCancel := context.WithCancel(context.Background())
 	defer uploadsCancel()
@@ -1178,7 +1177,7 @@ func selfSpeedtest(ctx context.Context, size, concurrent int, duration time.Dura
 		uploadsCancel()
 	}()
 
-	objNamePrefix := minioMetaSpeedTestBucketPrefix + uuid.New().String()
+	objNamePrefix := "speedtest/objects/" + uuid.New().String()
 
 	wg.Add(concurrent)
 	for i := 0; i < concurrent; i++ {
@@ -1198,7 +1197,7 @@ func selfSpeedtest(ctx context.Context, size, concurrent int, duration time.Dura
 					return
 				}
 				reader := NewPutObjReader(hashReader)
-				objInfo, err := objAPI.PutObject(uploadsCtx, bucket, fmt.Sprintf("%s.%d.%d",
+				objInfo, err := objAPI.PutObject(uploadsCtx, minioMetaBucket, fmt.Sprintf("%s.%d.%d",
 					objNamePrefix, i, objCountPerThread[i]), reader, ObjectOptions{
 					UserDefined: map[string]string{
 						xhttp.AmzStorageClass: storageClass,
@@ -1245,7 +1244,7 @@ func selfSpeedtest(ctx context.Context, size, concurrent int, duration time.Dura
 				if objCountPerThread[i] == j {
 					j = 0
 				}
-				r, err := objAPI.GetObjectNInfo(downloadsCtx, bucket, fmt.Sprintf("%s.%d.%d",
+				r, err := objAPI.GetObjectNInfo(downloadsCtx, minioMetaBucket, fmt.Sprintf("%s.%d.%d",
 					objNamePrefix, i, j), nil, nil, noLock, ObjectOptions{})
 				if err != nil {
 					if !contextCanceled(downloadsCtx) {


Test patch: