|
@@ -33,6 +33,7 @@ import (
|
|
|
"google.golang.org/grpc/credentials"
|
|
"google.golang.org/grpc/credentials"
|
|
|
"google.golang.org/grpc/keepalive"
|
|
"google.golang.org/grpc/keepalive"
|
|
|
"google.golang.org/grpc/metadata"
|
|
"google.golang.org/grpc/metadata"
|
|
|
|
|
+ "google.golang.org/grpc/status"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -478,14 +479,14 @@ func isHaltErr(ctx context.Context, err error) bool {
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
- code := grpc.Code(err)
|
|
|
|
|
|
|
+ ev, _ := status.FromError(err)
|
|
|
// Unavailable codes mean the system will be right back.
|
|
// Unavailable codes mean the system will be right back.
|
|
|
// (e.g., can't connect, lost leader)
|
|
// (e.g., can't connect, lost leader)
|
|
|
// Treat Internal codes as if something failed, leaving the
|
|
// Treat Internal codes as if something failed, leaving the
|
|
|
// system in an inconsistent state, but retrying could make progress.
|
|
// system in an inconsistent state, but retrying could make progress.
|
|
|
// (e.g., failed in middle of send, corrupted frame)
|
|
// (e.g., failed in middle of send, corrupted frame)
|
|
|
// TODO: are permanent Internal errors possible from grpc?
|
|
// TODO: are permanent Internal errors possible from grpc?
|
|
|
- return code != codes.Unavailable && code != codes.Internal
|
|
|
|
|
|
|
+ return ev.Code() != codes.Unavailable && ev.Code() != codes.Internal
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func toErr(ctx context.Context, err error) error {
|
|
func toErr(ctx context.Context, err error) error {
|
|
@@ -496,7 +497,8 @@ func toErr(ctx context.Context, err error) error {
|
|
|
if _, ok := err.(rpctypes.EtcdError); ok {
|
|
if _, ok := err.(rpctypes.EtcdError); ok {
|
|
|
return err
|
|
return err
|
|
|
}
|
|
}
|
|
|
- code := grpc.Code(err)
|
|
|
|
|
|
|
+ ev, _ := status.FromError(err)
|
|
|
|
|
+ code := ev.Code()
|
|
|
switch code {
|
|
switch code {
|
|
|
case codes.DeadlineExceeded:
|
|
case codes.DeadlineExceeded:
|
|
|
fallthrough
|
|
fallthrough
|