From 73ea39627c8209035ddd44406c64a655769823eb Mon Sep 17 00:00:00 2001 From: Yun Peng Date: Wed, 10 May 2023 14:46:34 +0200 Subject: [PATCH] Retry fetching GCS URL --- repositories/gcs.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/repositories/gcs.go b/repositories/gcs.go index 542e781d..d8a21327 100644 --- a/repositories/gcs.go +++ b/repositories/gcs.go @@ -77,7 +77,19 @@ 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 + for attempt := 0; attempt <= 5; attempt++ { + content, _, err = httputil.ReadRemoteFile(url, "") + if err == nil { + break + } + } + if err != nil { return nil, false, fmt.Errorf("could not list GCS objects at %s: %v", url, err) }