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

Retry fetching Bazel versions from GCS URL #459

Merged
merged 2 commits into from
May 10, 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
18 changes: 17 additions & 1 deletion repositories/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"log"
"strings"
"time"

"github.com/bazelbuild/bazelisk/core"
"github.com/bazelbuild/bazelisk/httputil"
Expand Down Expand Up @@ -77,7 +78,22 @@ func listDirectoriesInReleaseBucket(prefix string) ([]string, bool, error) {
if nextPageToken != "" {
url = fmt.Sprintf("%s&pageToken=%s", baseURL, nextPageToken)
}
content, _, err := httputil.ReadRemoteFile(url, "")

var content []byte
var err error
// Theoretically, this should always work, but we've seen transient
// errors on Bazel CI, so we retry a few times to work around this.
// https://github.com/bazelbuild/continuous-integration/issues/1627
waitTime := 100 * time.Microsecond
for attempt := 0; attempt < 5; attempt++ {
content, _, err = httputil.ReadRemoteFile(url, "")
if err == nil {
break
}
meteorcloudy marked this conversation as resolved.
Show resolved Hide resolved
time.Sleep(waitTime)
waitTime *= 2
}

if err != nil {
return nil, false, fmt.Errorf("could not list GCS objects at %s: %v", url, err)
}
Expand Down