Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#50534
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
lance6716 authored and ti-chi-bot committed Feb 27, 2024
1 parent cbd44d4 commit 0e76332
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions br/pkg/storage/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func newGCSStorage(ctx context.Context, gcs *backuppb.GCS, opts *ExternalStorage
}

bucket := client.Bucket(gcs.Bucket)
<<<<<<< HEAD
// check whether it's a bug before #647, to solve case #2
// If the storage is set as gcs://bucket/prefix/,
// the backupmeta is written correctly to gcs://bucket/prefix/backupmeta,
Expand All @@ -303,27 +304,25 @@ func newGCSStorage(ctx context.Context, gcs *backuppb.GCS, opts *ExternalStorage
gcs.Prefix += "//"
}
return &gcsStorage{gcs: gcs, bucket: bucket}, nil
=======
return &GCSStorage{gcs: gcs, bucket: bucket, cli: client}, nil
}

func hasSSTFiles(ctx context.Context, bucket *storage.BucketHandle, prefix string) bool {
query := storage.Query{Prefix: prefix}
_ = query.SetAttrSelection([]string{"Name"})
it := bucket.Objects(ctx, &query)
for {
attrs, err := it.Next()
if err == iterator.Done { // nolint:errorlint
break
}
if err != nil {
log.Warn("failed to list objects on gcs, will use default value for `prefix`", zap.Error(err))
break
}
if strings.HasSuffix(attrs.Name, ".sst") {
log.Info("sst file found in prefix slash", zap.String("file", attrs.Name))
func shouldRetry(err error) bool {
if storage.ShouldRetry(err) {
return true
}

// workaround for https://github.com/googleapis/google-cloud-go/issues/9262
if e := (&googleapi.Error{}); goerrors.As(err, &e) {
if e.Code == 401 && strings.Contains(e.Message, "Authentication required.") {
log.Warn("retrying gcs request due to internal authentication error", zap.Error(err))
return true
}
}

return false
>>>>>>> c92094fcb48 (external: remove old compatibility check of BR (#50534))
}

// gcsObjectReader wrap storage.Reader and add the `Seek` method.
Expand Down

0 comments on commit 0e76332

Please sign in to comment.