Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storage): update gRPC retry codes #8202

Merged
merged 2 commits into from Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions storage/invoke.go
Expand Up @@ -136,12 +136,11 @@ func ShouldRetry(err error) bool {
return true
}
}
// HTTP 429, 502, 503, and 504 all map to gRPC UNAVAILABLE per
// https://grpc.github.io/grpc/core/md_doc_http-grpc-status-mapping.html.
//
// This is only necessary for the experimental gRPC-based media operations.
if st, ok := status.FromError(err); ok && st.Code() == codes.Unavailable {
return true
// UNAVAILABLE, RESOURCE_EXHAUSTED, and INTERNAL codes are all retryable for gRPC.
if st, ok := status.FromError(err); ok {
if code := st.Code(); code == codes.Unavailable || code == codes.ResourceExhausted || code == codes.Internal {
return true
}
}
// Unwrap is only supported in go1.13.x+
if e, ok := err.(interface{ Unwrap() error }); ok {
Expand Down
8 changes: 8 additions & 0 deletions storage/invoke_test.go
Expand Up @@ -72,6 +72,14 @@ func TestInvoke(t *testing.T) {
isIdempotentValue: true,
expectFinalErr: true,
},
{
desc: "retryable gRPC error is retried",
count: 1,
initialErr: status.Error(codes.ResourceExhausted, "rate limit"),
finalErr: nil,
isIdempotentValue: true,
expectFinalErr: true,
},
{
desc: "returns non-retryable error after retryable error",
count: 1,
Expand Down