-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(artifacts): only retry on transient S3 errors (#5579)
- Loading branch information
Showing
4 changed files
with
486 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package s3 | ||
|
||
import argos3 "github.com/argoproj/pkg/s3" | ||
|
||
// 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{ | ||
"InternalError", | ||
"RequestTimeout", | ||
"Throttling", | ||
"ThrottlingException", | ||
"RequestLimitExceeded", | ||
"RequestThrottled", | ||
"InternalError", | ||
"SlowDown", | ||
} | ||
|
||
// 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 argos3.IsS3ErrCode(err, transientErrCode) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package s3 | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/minio/minio-go/v7" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIsTransientOSSErr(t *testing.T) { | ||
for _, errCode := range s3TransientErrorCodes { | ||
err := minio.ErrorResponse{Code: errCode} | ||
assert.True(t, isTransientS3Err(err)) | ||
} | ||
|
||
err := minio.ErrorResponse{Code: "NoSuchBucket"} | ||
assert.False(t, isTransientS3Err(err)) | ||
|
||
nonOSSErr := errors.New("UnseenError") | ||
assert.False(t, isTransientS3Err(nonOSSErr)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.