Skip to content

Commit

Permalink
fix failure TestIntegrationGCS, pool not open failure, add more reada…
Browse files Browse the repository at this point in the history
…ble error messages
  • Loading branch information
Slach committed Oct 18, 2023
1 parent 237ded8 commit ccff489
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/backup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,9 @@ func (b *Backuper) AddTableToBackup(ctx context.Context, backupName, shadowBacku
if err != nil {
return nil, nil, err
}
if err := b.dst.Connect(ctx); err != nil {
return nil, nil, fmt.Errorf("can't connect to %s: %v", b.dst.Kind(), err)
}
}
if err := b.dst.Connect(ctx); err != nil {
return nil, nil, fmt.Errorf("can't connect to %s: %v", b.dst.Kind(), err)
}
if size, err = b.uploadObjectDiskParts(ctx, backupName, backupShadowPath, disk); err != nil {
return disksToPartsMap, realSize, err
Expand Down
12 changes: 6 additions & 6 deletions pkg/storage/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,20 @@ func (gcs *GCS) Walk(ctx context.Context, gcsPath string, recursive bool, proces
func (gcs *GCS) GetFileReader(ctx context.Context, key string) (io.ReadCloser, error) {
pClientObj, err := gcs.clientPool.BorrowObject(ctx)
if err != nil {
log.Errorf("can't get client connection from pool: %+v", err)
log.Errorf("gcs.GetFileReader: gcs.clientPool.BorrowObject error: %+v", err)
return nil, err
}
pClient := pClientObj.(*clientObject).Client
obj := pClient.Bucket(gcs.Config.Bucket).Object(path.Join(gcs.Config.Path, key))
reader, err := obj.NewReader(ctx)
if err != nil {
if pErr := gcs.clientPool.InvalidateObject(ctx, pClientObj); pErr != nil {
log.Warnf("GetFileReader: gcs.clientPool.InvalidateObject error: %v ", pErr)
log.Warnf("gcs.GetFileReader: gcs.clientPool.InvalidateObject error: %v ", pErr)
}
return nil, err
}
if pErr := gcs.clientPool.ReturnObject(ctx, pClientObj); pErr != nil {
log.Warnf("GetFileReader: gcs.clientPool.ReturnObject error: %v ", pErr)
log.Warnf("gcs.GetFileReader: gcs.clientPool.ReturnObject error: %v ", pErr)
}
return reader, nil
}
Expand All @@ -193,7 +193,7 @@ func (gcs *GCS) GetFileReaderWithLocalPath(ctx context.Context, key, _ string) (
func (gcs *GCS) PutFile(ctx context.Context, key string, r io.ReadCloser) error {
pClientObj, err := gcs.clientPool.BorrowObject(ctx)
if err != nil {
log.Errorf("can't get client connection from pool: %+v", err)
log.Errorf("gcs.PutFile: gcs.clientPool.BorrowObject error: %+v", err)
return err
}
pClient := pClientObj.(*clientObject).Client
Expand Down Expand Up @@ -240,7 +240,7 @@ func (gcs *GCS) StatFile(ctx context.Context, key string) (RemoteFile, error) {
func (gcs *GCS) deleteKey(ctx context.Context, key string) error {
pClientObj, err := gcs.clientPool.BorrowObject(ctx)
if err != nil {
log.Errorf("can't get client connection from pool: %+v", err)
log.Errorf("gcs.deleteKey: gcs.clientPool.BorrowObject error: %+v", err)
return err
}
pClient := pClientObj.(*clientObject).Client
Expand Down Expand Up @@ -271,7 +271,7 @@ func (gcs *GCS) DeleteFileFromObjectDiskBackup(ctx context.Context, key string)
func (gcs *GCS) CopyObject(ctx context.Context, srcBucket, srcKey, dstKey string) (int64, error) {
pClientObj, err := gcs.clientPool.BorrowObject(ctx)
if err != nil {
log.Errorf("can't get client connection from pool: %+v", err)
log.Errorf("gcs.CopyObject: gcs.clientPool.BorrowObject error: %+v", err)
return 0, err
}
pClient := pClientObj.(*clientObject).Client
Expand Down

0 comments on commit ccff489

Please sign in to comment.