etcdserver, clientv3: handle a case of expired auth token

This commit adds a mechanism of handling a case of expired auth token
to clientv3. If a server returns an error code
grpc.codes.Unauthenticated, newRetryWrapper() tries to get a new token
and use it as an option of PerRPCCredential.

Fixes https://github.com/coreos/etcd/issues/7012
This commit is contained in:
Hitoshi Mitake
2017-01-05 00:59:10 +09:00
committed by Hitoshi Mitake
parent b32a8010a7
commit d431b64d97
4 changed files with 105 additions and 27 deletions

View File

@ -93,6 +93,8 @@ func togRPCError(err error) error {
return rpctypes.ErrGRPCPermissionNotGranted
case auth.ErrAuthNotEnabled:
return rpctypes.ErrGRPCAuthNotEnabled
case etcdserver.ErrInvalidAuthToken:
return rpctypes.ErrGRPCInvalidAuthToken
default:
return grpc.Errorf(codes.Unknown, err.Error())
}