Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a sleep to resolve race condition #221

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading