lib/backup/s3remote: fix error checking for alternative S3 providers (#3191)

This commit is contained in:
Zakhar Bessarab 2022-10-06 13:36:40 +03:00 committed by GitHub
parent dba49943d3
commit 97239e05ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,6 @@ package s3remote
import ( import (
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"strings" "strings"
@ -12,7 +11,6 @@ import (
"github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/backup/common" "github.com/VictoriaMetrics/VictoriaMetrics/lib/backup/common"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/backup/fscommon" "github.com/VictoriaMetrics/VictoriaMetrics/lib/backup/fscommon"
@ -307,7 +305,7 @@ func (fs *FS) HasFile(filePath string) (bool, error) {
} }
o, err := fs.s3.GetObject(context.Background(), input) o, err := fs.s3.GetObject(context.Background(), input)
if err != nil { if err != nil {
if errors.Is(err, &types.NoSuchKey{}) { if strings.Contains(err.Error(), "NoSuchKey") {
return false, nil return false, nil
} }
return false, fmt.Errorf("cannot open %q at %s (remote path %q): %w", filePath, fs, path, err) return false, fmt.Errorf("cannot open %q at %s (remote path %q): %w", filePath, fs, path, err)