Skip to content

Commit 94e8c2c

Browse files
authored
Merge pull request #152616 from cockroachdb/blathers/backport-release-25.3-152303
release-25.3: cloud: fix aws client option handling
2 parents 59317ae + d0097bc commit 94e8c2c

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

pkg/cloud/amazon/s3_storage.go

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -123,37 +123,6 @@ type s3Storage struct {
123123
cached *s3Client
124124
}
125125

126-
// customRetryer implements the `request.Retryer` interface and allows for
127-
// customization of the retry behaviour of an AWS client.
128-
type customRetryer struct{}
129-
130-
// isErrReadConnectionReset returns true if the underlying error is a read
131-
// connection reset error.
132-
//
133-
// NB: A read connection reset error is thrown when the SDK is unable to read
134-
// the response of an underlying API request due to a connection reset. The
135-
// DefaultRetryer in the AWS SDK does not treat this error as a retryable error
136-
// since the SDK does not have knowledge about the idempotence of the request,
137-
// and whether it is safe to retry -
138-
// https://github.com/aws/aws-sdk-go/pull/2926#issuecomment-553637658.
139-
//
140-
// In CRDB all operations with s3 (read, write, list) are considered idempotent,
141-
// and so we can treat the read connection reset error as retryable too.
142-
func isErrReadConnectionReset(err error) bool {
143-
// The error string must match the one in
144-
// github.com/aws/aws-sdk-go/aws/request/connection_reset_error.go. This is
145-
// unfortunate but the only solution until the SDK exposes a specialized error
146-
// code or type for this class of errors.
147-
return err != nil && strings.Contains(err.Error(), "read: connection reset")
148-
}
149-
150-
// IsErrorRetryable implements the retry.IsErrorRetryable interface.
151-
func (sr *customRetryer) IsErrorRetryable(e error) aws.Ternary {
152-
return aws.BoolTernary(isErrReadConnectionReset(e))
153-
}
154-
155-
var _ retry.IsErrorRetryable = &customRetryer{}
156-
157126
// s3Client wraps an SDK client and uploader for a given session.
158127
type s3Client struct {
159128
client *s3.Client
@@ -647,23 +616,18 @@ func (s *s3Storage) newClient(ctx context.Context) (s3Client, string, error) {
647616
return s3Client{}, "", err
648617
}
649618
addLoadOption(config.WithHTTPClient(client))
650-
651-
retryMaxAttempts := int(maxRetries.Get(&s.settings.SV))
652-
addLoadOption(config.WithRetryMaxAttempts(retryMaxAttempts))
653-
654619
addLoadOption(config.WithLogger(newLogAdapter(ctx)))
655620
if s.opts.logMode != 0 {
656621
addLoadOption(config.WithClientLogMode(s.opts.logMode))
657622
}
658-
config.WithRetryer(func() aws.Retryer {
623+
addLoadOption(config.WithRetryer(func() aws.Retryer {
659624
return retry.NewStandard(func(opts *retry.StandardOptions) {
660-
opts.MaxAttempts = retryMaxAttempts
661-
opts.Retryables = append(opts.Retryables, &customRetryer{})
625+
opts.MaxAttempts = int(maxRetries.Get(&s.settings.SV))
662626
if !enableClientRetryTokenBucket.Get(&s.settings.SV) {
663627
opts.RateLimiter = ratelimit.None
664628
}
665629
})
666-
})
630+
}))
667631

668632
switch s.opts.auth {
669633
case "", cloud.AuthParamSpecified:

0 commit comments

Comments
 (0)