From 1defeda792f44a083769497c626c12661dc961ba Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Wed, 7 Sep 2016 16:51:49 -0700 Subject: [PATCH] v3api, rpctypes: add ErrUnhealthy --- etcdserver/api/v3rpc/rpctypes/error.go | 3 +++ etcdserver/api/v3rpc/util.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/etcdserver/api/v3rpc/rpctypes/error.go b/etcdserver/api/v3rpc/rpctypes/error.go index 7461a84ca4a..183a04f3a80 100644 --- a/etcdserver/api/v3rpc/rpctypes/error.go +++ b/etcdserver/api/v3rpc/rpctypes/error.go @@ -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, @@ -93,6 +94,7 @@ var ( grpc.ErrorDesc(ErrGRPCStopped): ErrGRPCStopped, grpc.ErrorDesc(ErrGRPCTimeout): ErrGRPCTimeout, grpc.ErrorDesc(ErrGRPCTimeoutDueToLeaderFail): ErrGRPCTimeoutDueToLeaderFail, + grpc.ErrorDesc(ErrGRPCUnhealthy): ErrGRPCUnhealthy, } // client-side error @@ -131,6 +133,7 @@ var ( ErrStopped = Error(ErrGRPCStopped) ErrTimeout = Error(ErrGRPCTimeout) ErrTimeoutDueToLeaderFail = Error(ErrGRPCTimeoutDueToLeaderFail) + ErrUnhealthy = Error(ErrGRPCUnhealthy) ) // EtcdError defines gRPC server errors. diff --git a/etcdserver/api/v3rpc/util.go b/etcdserver/api/v3rpc/util.go index 33ccfe7d20f..5210bdcf6ef 100644 --- a/etcdserver/api/v3rpc/util.go +++ b/etcdserver/api/v3rpc/util.go @@ -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