|
|
@@ -48,6 +48,11 @@ func newUnaryInterceptor(s *etcdserver.EtcdServer) grpc.UnaryServerInterceptor {
|
|
|
return nil, rpctypes.ErrGRPCNotCapable
|
|
|
}
|
|
|
|
|
|
+ // TODO: add test in clientv3/integration to verify behavior
|
|
|
+ if s.IsLearner() && !isRPCEnabledForLearner(req) {
|
|
|
+ return nil, rpctypes.ErrGPRCNotSupportedForLearner
|
|
|
+ }
|
|
|
+
|
|
|
md, ok := metadata.FromIncomingContext(ctx)
|
|
|
if ok {
|
|
|
if ks := md[rpctypes.MetadataRequireLeaderKey]; len(ks) > 0 && ks[0] == rpctypes.MetadataHasLeader {
|
|
|
@@ -190,6 +195,10 @@ func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor
|
|
|
return rpctypes.ErrGRPCNotCapable
|
|
|
}
|
|
|
|
|
|
+ if s.IsLearner() { // learner does not support Watch and LeaseKeepAlive RPC
|
|
|
+ return rpctypes.ErrGPRCNotSupportedForLearner
|
|
|
+ }
|
|
|
+
|
|
|
md, ok := metadata.FromIncomingContext(ss.Context())
|
|
|
if ok {
|
|
|
if ks := md[rpctypes.MetadataRequireLeaderKey]; len(ks) > 0 && ks[0] == rpctypes.MetadataHasLeader {
|