Skip to content

Commit

Permalink
Merge pull request #221 from ericzbeard/fix-213
Browse files Browse the repository at this point in the history
Adding a sleep to resolve race condition
  • Loading branch information
ericzbeard authored Dec 11, 2023
2 parents ff1e338 + d0dc302 commit 1e406cd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/aws/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"io"
"path/filepath"
"time"

"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
Expand Down Expand Up @@ -199,6 +200,34 @@ func RainBucket(forceCreation bool) string {
}
}

// Sleep for 2 seconds to give the bucket time to stabilize
time.Sleep(2 * time.Second)

// #213
// Confirm that the bucket really does exist.
// Seems unnecessary but bug 213 looks like a race condition. Maybe
// checking here and pausing a few seconds will be enough?
isBucketExists, err = BucketExists(bucketName)
if err != nil {
config.Debugf("unable to confirm bucket after creation: %v", err)
}

if !isBucketExists {
// Sleep for 5 seconds
time.Sleep(5 * time.Second)

// Check again
isBucketExists, err = BucketExists(bucketName)
if err != nil {
panic(fmt.Errorf("unable to re-confirm whether artifact bucket exists: %w", err))
}

// Give up
if !isBucketExists {
panic(fmt.Errorf("cannot confirm that artifact bucket '%s' exists", bucketName))
}
}

return bucketName
}

Expand Down

0 comments on commit 1e406cd

Please sign in to comment.