etcdserver/api/v3rpc: set grpclog once
@@ -19,6 +19,7 @@ import (
"io/ioutil"
"math"
"os"
+ "sync"
"github.com/coreos/etcd/etcdserver"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
@@ -37,6 +38,9 @@ const (
maxSendBytes = math.MaxInt32
)
+// integration tests call this multiple times, which is racey in gRPC side
+var grpclogOnce sync.Once
+
func Server(s *etcdserver.EtcdServer, tls *tls.Config, gopts ...grpc.ServerOption) *grpc.Server {
var opts []grpc.ServerOption
opts = append(opts, grpc.CustomCodec(&codec{}))
@@ -67,6 +71,7 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config, gopts ...grpc.ServerOptio
// set zero values for metrics registered for this grpc server
grpc_prometheus.Register(grpcServer)
+ grpclogOnce.Do(func() {
if s.Cfg.Debug {
grpc.EnableTracing = true
// enable info, warning, error
@@ -75,5 +80,7 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config, gopts ...grpc.ServerOptio
// only discard info
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
}
+ })
+
return grpcServer
}
