Return the error if velero failed to detect S3 region for restic repo (#4343)
The error should be returned explicitly, because when the default URL is used S3 will return a 301 and the response can't be handled by restic. Fixes #4178 Signed-off-by: Daniel Jiang <jiangd@vmware.com>pull/4372/head
parent
983489073f
commit
130602d723
|
@ -0,0 +1 @@
|
|||
Return the error if velero failed to detect S3 region for restic repo
|
|
@ -74,10 +74,9 @@ func getRepoPrefix(location *velerov1api.BackupStorageLocation) (string, error)
|
|||
region, err = getAWSBucketRegion(bucket)
|
||||
}
|
||||
if err != nil {
|
||||
url = "s3.amazonaws.com"
|
||||
} else {
|
||||
url = fmt.Sprintf("s3-%s.amazonaws.com", region)
|
||||
return "", errors.Wrapf(err, "failed to detect the region via bucket: %s", bucket)
|
||||
}
|
||||
url = fmt.Sprintf("s3-%s.amazonaws.com", region)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("s3:%s/%s", url, path.Join(bucket, prefix)), nil
|
||||
|
|
|
@ -85,7 +85,8 @@ func TestGetRepoIdentifier(t *testing.T) {
|
|||
getAWSBucketRegion: func(string) (string, error) {
|
||||
return "", errors.New("no region found")
|
||||
},
|
||||
expected: "s3:s3.amazonaws.com/bucket/restic/repo-1",
|
||||
expected: "",
|
||||
expectedErr: "failed to detect the region via bucket: bucket: no region found",
|
||||
},
|
||||
{
|
||||
name: "s3.s3-<region>.amazonaws.com URL format is used if region can be determined for AWS BSL",
|
||||
|
|
Loading…
Reference in New Issue