Skip to content

Commit

Permalink
Merge pull request #6382 from heyitsanthony/unhealthy-err
Browse files Browse the repository at this point in the history
v3api, rpctypes: add ErrUnhealthy
  • Loading branch information
Anthony Romano authored Sep 8, 2016
2 parents 0cc2f82 + 1defeda commit 4563efd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions etcdserver/api/v3rpc/rpctypes/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
ErrGRPCStopped = grpc.Errorf(codes.Unavailable, "etcdserver: server stopped")
ErrGRPCTimeout = grpc.Errorf(codes.Unavailable, "etcdserver: request timed out")
ErrGRPCTimeoutDueToLeaderFail = grpc.Errorf(codes.Unavailable, "etcdserver: request timed out, possibly due to previous leader failure")
ErrGRPCUnhealthy = grpc.Errorf(codes.Unavailable, "etcdserver: unhealthy cluster")

errStringToError = map[string]error{
grpc.ErrorDesc(ErrGRPCEmptyKey): ErrGRPCEmptyKey,
Expand Down Expand Up @@ -93,6 +94,7 @@ var (
grpc.ErrorDesc(ErrGRPCStopped): ErrGRPCStopped,
grpc.ErrorDesc(ErrGRPCTimeout): ErrGRPCTimeout,
grpc.ErrorDesc(ErrGRPCTimeoutDueToLeaderFail): ErrGRPCTimeoutDueToLeaderFail,
grpc.ErrorDesc(ErrGRPCUnhealthy): ErrGRPCUnhealthy,
}

// client-side error
Expand Down Expand Up @@ -131,6 +133,7 @@ var (
ErrStopped = Error(ErrGRPCStopped)
ErrTimeout = Error(ErrGRPCTimeout)
ErrTimeoutDueToLeaderFail = Error(ErrGRPCTimeoutDueToLeaderFail)
ErrUnhealthy = Error(ErrGRPCUnhealthy)
)

// EtcdError defines gRPC server errors.
Expand Down
2 changes: 2 additions & 0 deletions etcdserver/api/v3rpc/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func togRPCError(err error) error {
return rpctypes.ErrGRPCTimeout
case etcdserver.ErrTimeoutDueToLeaderFail:
return rpctypes.ErrGRPCTimeoutDueToLeaderFail
case etcdserver.ErrUnhealthy:
return rpctypes.ErrGRPCUnhealthy

case auth.ErrRootUserNotExist:
return rpctypes.ErrGRPCRootUserNotExist
Expand Down

0 comments on commit 4563efd

Please sign in to comment.