forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.go
More file actions
48 lines (43 loc) · 1.46 KB
/
Copy patherrors.go
File metadata and controls
48 lines (43 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package s3
import (
stderrors "errors"
"github.com/minio/minio-go/v7"
log "github.com/sirupsen/logrus"
"github.com/argoproj/argo-workflows/v3/util/errors"
)
// s3TransientErrorCodes is a list of S3 error codes that are transient (retryable)
// Reference: https://github.com/minio/minio-go/blob/92fe50d14294782d96402deb861d442992038109/retry.go#L90-L102
var s3TransientErrorCodes = []string{
"RequestError",
"RequestTimeout",
"Throttling",
"ThrottlingException",
"RequestLimitExceeded",
"RequestThrottled",
"InternalError",
"SlowDown",
"ServiceUnavailable",
}
// isTransientS3Err checks if an minio.ErrorResponse error is transient (retryable)
func isTransientS3Err(err error) bool {
if err == nil {
return false
}
for _, transientErrCode := range s3TransientErrorCodes {
if IsS3ErrCode(err, transientErrCode) {
log.Errorf("Transient S3 error: %v", err)
return true
}
}
// When the response body is not a parsable S3 XML document (e.g. a proxy
// or load balancer returned a bare 5xx response), minio-go sets Code to
// the raw HTTP status string ("503 Service Unavailable"), which does not
// match any entry in s3TransientErrorCodes. Fall back to StatusCode so
// 5xx responses are still treated as transient per S3 retry semantics.
var minioErr minio.ErrorResponse
if stderrors.As(err, &minioErr) && minioErr.StatusCode >= 500 && minioErr.StatusCode < 600 {
log.Errorf("Transient S3 error: %v", err)
return true
}
return errors.IsTransientErr(err)
}