Skip to content

Commit

Permalink
Revert "simplify makeBucket behavior (#77)" (#87)
Browse files Browse the repository at this point in the history
This reverts commit bd5cc3d.
This way we don't require permission to create it if it already exists.
  • Loading branch information
klauspost authored Mar 20, 2020
1 parent 9750e13 commit 189c7f4
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions pkg/bench/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,26 @@ func (c *Common) GetCommon() *Common {
func (c *Common) createEmptyBucket(ctx context.Context) error {
cl, done := c.Client()
defer done()

console.Infof("Creating Bucket %q...\n", c.Bucket)
// In client mode someone else may have created it
// first. Check if it exists now. We don't test
// against a specific error since we might run
// against many different servers.
if err := cl.MakeBucket(c.Bucket, c.Location); err != nil {
switch minio.ToErrorResponse(err).Code {
case "BucketAlreadyOwnedByYou":
case "BucketAlreadyExists":
default:
return err
x, err := cl.BucketExists(c.Bucket)
if err != nil {
return err
}
if !x {
console.Infof("Creating Bucket %q...\n", c.Bucket)
err := cl.MakeBucket(c.Bucket, c.Location)

// In client mode someone else may have created it first.
// Check if it exists now.
// We don't test against a specific error since we might run against many different servers.
if err != nil {
x, err2 := cl.BucketExists(c.Bucket)
if err2 != nil {
return err2
}
if !x {
// It still doesn't exits, return original error.
return err
}
}
}
if c.Clear {
Expand Down

0 comments on commit 189c7f4

Please sign in to comment.