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

server: add diagnostics service #2024

Merged
merged 1 commit into from
Dec 16, 2019
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
2 changes: 0 additions & 2 deletions conf/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ level = "info"
# max-days = 28
## maximum number of old log files to retain
# max-backups = 7
## rotate log by day
# log-rotate = true

[metric]
## prometheus client push interval, set "0s" to disable prometheus.
Expand Down
19 changes: 8 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@ require (
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/gogo/protobuf v1.0.0
github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
github.com/golang/protobuf v1.2.0
github.com/golang/protobuf v1.3.2
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect
github.com/gorilla/mux v1.6.1
github.com/gorilla/websocket v1.2.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/juju/ratelimit v1.0.1
github.com/kr/pretty v0.1.0 // indirect
github.com/mattn/go-shellwords v1.0.3
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/montanaflynn/stats v0.0.0-20151014174947-eeaced052adb
github.com/opentracing/opentracing-go v1.0.2
github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
github.com/pingcap/check v0.0.0-20191107115940-caf2b9e6ccf4
github.com/pingcap/errcode v0.0.0-20180921232412-a1a7271709d9
github.com/pingcap/failpoint v0.0.0-20190512135322-30cc7431d99c
github.com/pingcap/kvproto v0.0.0-20191030021250-51b332bcb20b
github.com/pingcap/log v0.0.0-20190715063458-479153f07ebd
github.com/pingcap/failpoint v0.0.0-20191029060244-12f4ac2fd11d
github.com/pingcap/kvproto v0.0.0-20191213111810-93cb7c623c8b
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9
github.com/pingcap/sysutil v0.0.0-20191216090214-5f9620d22b3b
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v0.8.0
github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5 // indirect
github.com/sirupsen/logrus v1.0.5
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.1
Expand All @@ -46,12 +45,10 @@ require (
github.com/urfave/negroni v0.3.0
go.etcd.io/etcd v0.0.0-20190320044326-77d4b742cdbf
go.uber.org/goleak v0.10.0
go.uber.org/zap v1.9.1
go.uber.org/zap v1.12.0
golang.org/x/crypto v0.0.0-20190909091759-094676da4a83 // indirect
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
golang.org/x/sys v0.0.0-20190909082730-f460065e899a // indirect
google.golang.org/grpc v1.14.0
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
google.golang.org/grpc v1.25.1
gopkg.in/natefinch/lumberjack.v2 v2.0.0
)
95 changes: 87 additions & 8 deletions go.sum

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions pkg/logutil/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const (
type FileLogConfig struct {
// Log filename, leave empty to disable file log.
Filename string `toml:"filename" json:"filename"`
// Is log rotate enabled. TODO.
LogRotate bool `toml:"log-rotate" json:"log-rotate"`
// Max size for a single file, in MB.
MaxSize int `toml:"max-size" json:"max-size"`
// Max log keep days, default is never deleting.
Expand Down
1 change: 1 addition & 0 deletions pkg/testutil/leak.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var LeakOptions = []goleak.Option{
goleak.IgnoreTopFunction("google.golang.org/grpc.(*ccBalancerWrapper).watcher"),
goleak.IgnoreTopFunction("google.golang.org/grpc.(*ccResolverWrapper).watcher"),
goleak.IgnoreTopFunction("google.golang.org/grpc.(*addrConn).createTransport"),
goleak.IgnoreTopFunction("google.golang.org/grpc.(*addrConn).resetTransport"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/pkg/logutil.(*MergeLogger).outputLoop"),
// TODO: remove the below options once we fixed the http connection leak problems
goleak.IgnoreTopFunction("internal/poll.runtime_pollWait"),
Expand Down
1 change: 0 additions & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func NewConfig() *Config {

fs.StringVar(&cfg.Log.Level, "L", "", "log level: debug, info, warn, error, fatal (default 'info')")
fs.StringVar(&cfg.Log.File.Filename, "log-file", "", "log file path")
fs.BoolVar(&cfg.Log.File.LogRotate, "log-rotate", true, "rotate log")
lonng marked this conversation as resolved.
Show resolved Hide resolved

fs.StringVar(&cfg.Security.CAPath, "cacert", "", "Path of file that contains list of trusted TLS CAs")
fs.StringVar(&cfg.Security.CertPath, "cert", "", "Path of file that contains X509 certificate in PEM format")
Expand Down
16 changes: 12 additions & 4 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/gorilla/mux"
"github.com/pingcap/failpoint"
"github.com/pingcap/kvproto/pkg/diagnosticspb"
"github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"
Expand All @@ -46,6 +47,7 @@ import (
syncer "github.com/pingcap/pd/server/region_syncer"
"github.com/pingcap/pd/server/schedule/opt"
"github.com/pingcap/pd/server/tso"
"github.com/pingcap/sysutil"
"github.com/pkg/errors"
"github.com/urfave/negroni"
"go.etcd.io/etcd/clientv3"
Expand All @@ -72,6 +74,8 @@ var EnableZap = false

// Server is the pd server.
type Server struct {
diagnosticspb.DiagnosticsServer

// Server state.
isServing int64

Expand Down Expand Up @@ -169,9 +173,10 @@ func CreateServer(cfg *config.Config, apiBuilders ...HandlerBuilder) (*Server, e
rand.Seed(time.Now().UnixNano())

s := &Server{
cfg: cfg,
scheduleOpt: config.NewScheduleOption(cfg),
member: &member.Member{},
DiagnosticsServer: sysutil.NewDiagnosticsServer(cfg.Log.File.Filename),
cfg: cfg,
scheduleOpt: config.NewScheduleOption(cfg),
member: &member.Member{},
}
s.handler = newHandler(s)

Expand All @@ -191,7 +196,10 @@ func CreateServer(cfg *config.Config, apiBuilders ...HandlerBuilder) (*Server, e
webPath: http.StripPrefix(webPath, ui.Handler()),
}
}
etcdCfg.ServiceRegister = func(gs *grpc.Server) { pdpb.RegisterPDServer(gs, s) }
etcdCfg.ServiceRegister = func(gs *grpc.Server) {
pdpb.RegisterPDServer(gs, s)
diagnosticspb.RegisterDiagnosticsServer(gs, s)
}
s.etcdCfg = etcdCfg
if EnableZap {
// The etcd master version has removed embed.Config.SetupLogging.
Expand Down