Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

etcdserver: log stream error with debug level, silence gRPC server info level logs #9080

Merged
merged 4 commits into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
AuthToken: cfg.AuthToken,
InitialCorruptCheck: cfg.ExperimentalInitialCorruptCheck,
CorruptCheckTime: cfg.ExperimentalCorruptCheckTime,
Debug: cfg.Debug,
}

if e.Server, err = etcdserver.NewServer(srvcfg); err != nil {
Expand Down
18 changes: 15 additions & 3 deletions etcdserver/api/v3rpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ package v3rpc

import (
"crypto/tls"
"io/ioutil"
"math"
"os"
"sync"

"github.com/coreos/etcd/etcdserver"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
Expand All @@ -36,9 +38,8 @@ const (
maxSendBytes = math.MaxInt32
)

func init() {
grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr))
}
// 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
Expand Down Expand Up @@ -70,5 +71,16 @@ 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
grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr))
} else {
// only discard info
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
}
})

return grpcServer
}
4 changes: 2 additions & 2 deletions etcdserver/api/v3rpc/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (ls *LeaseServer) leaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) erro
return nil
}
if err != nil {
plog.Warningf("failed to receive lease keepalive request from gRPC stream (%q)", err.Error())
plog.Debugf("failed to receive lease keepalive request from gRPC stream (%q)", err.Error())
return err
}

Expand All @@ -133,7 +133,7 @@ func (ls *LeaseServer) leaseKeepAlive(stream pb.Lease_LeaseKeepAliveServer) erro
resp.TTL = ttl
err = stream.Send(resp)
if err != nil {
plog.Warningf("failed to send lease keepalive response to gRPC stream (%q)", err.Error())
plog.Debugf("failed to send lease keepalive response to gRPC stream (%q)", err.Error())
return err
}
}
Expand Down
8 changes: 4 additions & 4 deletions etcdserver/api/v3rpc/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (ws *watchServer) Watch(stream pb.Watch_WatchServer) (err error) {
// deadlock when calling sws.close().
go func() {
if rerr := sws.recvLoop(); rerr != nil {
plog.Warningf("failed to receive watch request from gRPC stream (%q)", rerr.Error())
plog.Debugf("failed to receive watch request from gRPC stream (%q)", rerr.Error())
errc <- rerr
}
}()
Expand Down Expand Up @@ -339,7 +339,7 @@ func (sws *serverWatchStream) sendLoop() {

mvcc.ReportEventReceived(len(evs))
if err := sws.gRPCStream.Send(wr); err != nil {
plog.Warningf("failed to send watch response to gRPC stream (%q)", err.Error())
plog.Debugf("failed to send watch response to gRPC stream (%q)", err.Error())
return
}

Expand All @@ -356,7 +356,7 @@ func (sws *serverWatchStream) sendLoop() {
}

if err := sws.gRPCStream.Send(c); err != nil {
plog.Warningf("failed to send watch control response to gRPC stream (%q)", err.Error())
plog.Debugf("failed to send watch control response to gRPC stream (%q)", err.Error())
return
}

Expand All @@ -372,7 +372,7 @@ func (sws *serverWatchStream) sendLoop() {
for _, v := range pending[wid] {
mvcc.ReportEventReceived(len(v.Events))
if err := sws.gRPCStream.Send(v); err != nil {
plog.Warningf("failed to send pending watch response to gRPC stream (%q)", err.Error())
plog.Debugf("failed to send pending watch response to gRPC stream (%q)", err.Error())
return
}
}
Expand Down
2 changes: 2 additions & 0 deletions etcdserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type ServerConfig struct {
// before serving any peer/client traffic.
InitialCorruptCheck bool
CorruptCheckTime time.Duration

Debug bool
}

// VerifyBootstrap sanity-checks the initial config for bootstrap case
Expand Down
4 changes: 0 additions & 4 deletions tools/functional-tester/etcd-tester/stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ package main

import (
"fmt"
"os"
"strings"
"sync"
"time"

"golang.org/x/time/rate"
"google.golang.org/grpc/grpclog"
)

func init() { grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr)) }

type Stresser interface {
// Stress starts to stress the etcd cluster
Stress() error
Expand Down