Skip to content

Commit 993986d

Browse files
author
Hongyu Zhou
committed
revert replacing awserr with smithy-go
1 parent 7024188 commit 993986d

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ require (
99
github.com/aws/aws-sdk-go-v2/config v1.18.32
1010
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.73
1111
github.com/aws/aws-sdk-go-v2/service/s3 v1.37.0
12-
github.com/aws/smithy-go v1.14.0
1312
github.com/fsnotify/fsnotify v1.5.1
1413
github.com/go-sql-driver/mysql v1.4.1
1514
github.com/google/go-cmp v0.5.8
@@ -43,6 +42,7 @@ require (
4342
github.com/aws/aws-sdk-go-v2/service/sso v1.13.1 // indirect
4443
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.1 // indirect
4544
github.com/aws/aws-sdk-go-v2/service/sts v1.21.1 // indirect
45+
github.com/aws/smithy-go v1.14.0 // indirect
4646
github.com/davecgh/go-spew v1.1.1 // indirect
4747
github.com/jmespath/go-jmespath v0.4.0 // indirect
4848
github.com/klauspost/compress v1.16.7 // indirect

pkg/reflector/download.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package reflector
33
import (
44
"bytes"
55
"context"
6-
er "errors"
76
"fmt"
87
"io"
8+
"net/http"
99
"os"
1010
"strings"
1111
"time"
@@ -14,8 +14,7 @@ import (
1414
"github.com/aws/aws-sdk-go-v2/config"
1515
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
1616
"github.com/aws/aws-sdk-go-v2/service/s3"
17-
"github.com/aws/aws-sdk-go-v2/service/s3/types"
18-
"github.com/aws/smithy-go"
17+
"github.com/aws/aws-sdk-go/aws/awserr"
1918
gzip "github.com/klauspost/pgzip"
2019

2120
"github.com/segmentio/ctlstore/pkg/errs"
@@ -61,14 +60,11 @@ func (d *S3Downloader) DownloadTo(w io.Writer) (n int64, err error) {
6160
stats.Observe("snapshot_download_time", time.Now().Sub(start))
6261

6362
if err != nil {
64-
var apiErr smithy.APIError
65-
if er.As(err, &apiErr) {
66-
switch apiErr.(type) {
67-
case *types.NotFound:
68-
if d.StartOverOnNotFound {
69-
// don't bother retrying. we'll start with a fresh ldb.
70-
return -1, errors.WithTypes(errors.Wrap(err, "get s3 data"), errs.ErrTypePermanent)
71-
}
63+
switch err := err.(type) {
64+
case awserr.RequestFailure:
65+
if d.StartOverOnNotFound && err.StatusCode() == http.StatusNotFound {
66+
// don't bother retrying. we'll start with a fresh ldb.
67+
return -1, errors.WithTypes(errors.Wrap(err, "get s3 data"), errs.ErrTypePermanent)
7268
}
7369
}
7470
// retry

0 commit comments

Comments
 (0)