-
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(executor): fix GCS artifact retry (#6302)
Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
- Loading branch information
1 parent
0b0f527
commit cc84fe9
Showing
2 changed files
with
82 additions
and
7 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
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,38 @@ | ||
package gcs | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"net/url" | ||
"testing" | ||
|
||
"google.golang.org/api/googleapi" | ||
) | ||
|
||
type tlsHandshakeTimeoutError struct{} | ||
|
||
func (tlsHandshakeTimeoutError) Temporary() bool { return true } | ||
func (tlsHandshakeTimeoutError) Error() string { return "net/http: TLS handshake timeout" } | ||
|
||
func TestIsTransientGCSErr(t *testing.T) { | ||
for _, test := range []struct { | ||
err error | ||
shouldretry bool | ||
}{ | ||
{&googleapi.Error{Code: 0}, false}, | ||
{&googleapi.Error{Code: 429}, true}, | ||
{&googleapi.Error{Code: 518}, true}, | ||
{&googleapi.Error{Code: 599}, true}, | ||
{&url.Error{Op: "blah", URL: "blah", Err: errors.New("connection refused")}, true}, | ||
{io.ErrUnexpectedEOF, true}, | ||
{&tlsHandshakeTimeoutError{}, true}, | ||
{fmt.Errorf("Test unwrapping of a temporary error: %w", &googleapi.Error{Code: 500}), true}, | ||
{fmt.Errorf("Test unwrapping of a non-retriable error: %w", &googleapi.Error{Code: 400}), false}, | ||
} { | ||
got := isTransientGCSErr(test.err) | ||
if got != test.shouldretry { | ||
t.Errorf("%+v: got %v, want %v", test, got, test.shouldretry) | ||
} | ||
} | ||
} |