From e020f3625d65cba922dde6f5ff4ea661e86cc670 Mon Sep 17 00:00:00 2001 From: Kemal Akkoyun Date: Wed, 30 Oct 2019 17:37:11 +0100 Subject: [PATCH] Fix review issues Signed-off-by: Kemal Akkoyun --- cmd/thanos/bucket.go | 29 ++++++++++++++--------------- cmd/thanos/compact.go | 5 ++--- cmd/thanos/downsample.go | 19 +++++++++---------- cmd/thanos/flags.go | 4 ++-- cmd/thanos/query.go | 27 +++++++++++++-------------- cmd/thanos/receive.go | 19 +++++++++---------- cmd/thanos/rule.go | 34 +++++++++++++++++----------------- cmd/thanos/sidecar.go | 19 ++++++++++--------- cmd/thanos/store.go | 15 +++++++-------- docs/components/compact.md | 2 +- docs/components/query.md | 4 ++-- docs/components/rule.md | 4 ++-- docs/components/sidecar.md | 4 ++-- docs/components/store.md | 4 ++-- go.mod | 3 +-- go.sum | 3 +++ pkg/server/grpc/grpc.go | 15 +++++---------- pkg/server/http/http.go | 14 ++++---------- pkg/ui/bucket.go | 4 ++-- 19 files changed, 107 insertions(+), 121 deletions(-) diff --git a/cmd/thanos/bucket.go b/cmd/thanos/bucket.go index e4bfc90802..244d8942a1 100644 --- a/cmd/thanos/bucket.go +++ b/cmd/thanos/bucket.go @@ -10,6 +10,15 @@ import ( "text/template" "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "github.com/oklog/run" + "github.com/oklog/ulid" + "github.com/olekukonko/tablewriter" + opentracing "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/prometheus/tsdb/labels" "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/compact" @@ -20,19 +29,9 @@ import ( "github.com/thanos-io/thanos/pkg/objstore/client" "github.com/thanos-io/thanos/pkg/prober" "github.com/thanos-io/thanos/pkg/runutil" - "github.com/thanos-io/thanos/pkg/server" + httpserver "github.com/thanos-io/thanos/pkg/server/http" "github.com/thanos-io/thanos/pkg/ui" "github.com/thanos-io/thanos/pkg/verifier" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/oklog/run" - "github.com/oklog/ulid" - "github.com/olekukonko/tablewriter" - opentracing "github.com/opentracing/opentracing-go" - "github.com/pkg/errors" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/prometheus/tsdb/labels" "golang.org/x/text/language" "golang.org/x/text/message" kingpin "gopkg.in/alecthomas/kingpin.v2" @@ -311,7 +310,7 @@ func registerBucketInspect(m map[string]setupFunc, root *kingpin.CmdClause, name func registerBucketWeb(m map[string]setupFunc, root *kingpin.CmdClause, name string, objStoreConfig *extflag.PathOrContent) { cmd := root.Command("web", "Web interface for remote storage bucket") bind := cmd.Flag("listen", "HTTP host:port to listen on").Default("0.0.0.0:8080").String() - httpGracePeriod := regHTTPGracePeriodFlag(cmd) + _, httpGracePeriod := regHTTPFlags(cmd) interval := cmd.Flag("refresh", "Refresh interval to download metadata from remote storage").Default("30m").Duration() timeout := cmd.Flag("timeout", "Timeout to download metadata from remote storage").Default("5m").Duration() label := cmd.Flag("label", "Prometheus label to use as timeline title").String() @@ -321,9 +320,9 @@ func registerBucketWeb(m map[string]setupFunc, root *kingpin.CmdClause, name str statusProber := prober.NewProber(component.Bucket, logger, prometheus.WrapRegistererWithPrefix("thanos_", reg)) // Initiate HTTP listener providing metrics endpoint and readiness/liveness probes. - srv := server.NewHTTP(logger, reg, component.Bucket, statusProber, - server.WithListen(*bind), - server.WithGracePeriod(time.Duration(*httpGracePeriod)), + srv := httpserver.New(logger, reg, component.Bucket, statusProber, + httpserver.WithListen(*bind), + httpserver.WithGracePeriod(time.Duration(*httpGracePeriod)), ) bucketUI := ui.NewBucketUI(logger, *label) diff --git a/cmd/thanos/compact.go b/cmd/thanos/compact.go index 8c5717e4df..ba09994913 100644 --- a/cmd/thanos/compact.go +++ b/cmd/thanos/compact.go @@ -10,9 +10,6 @@ import ( "strings" "time" - "github.com/thanos-io/thanos/pkg/extflag" - httpserver "github.com/thanos-io/thanos/pkg/server/http" - "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/oklog/run" @@ -25,10 +22,12 @@ import ( "github.com/thanos-io/thanos/pkg/compact" "github.com/thanos-io/thanos/pkg/compact/downsample" "github.com/thanos-io/thanos/pkg/component" + "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/objstore" "github.com/thanos-io/thanos/pkg/objstore/client" "github.com/thanos-io/thanos/pkg/prober" "github.com/thanos-io/thanos/pkg/runutil" + httpserver "github.com/thanos-io/thanos/pkg/server/http" "gopkg.in/alecthomas/kingpin.v2" ) diff --git a/cmd/thanos/downsample.go b/cmd/thanos/downsample.go index b03e2ef388..655bc20b63 100644 --- a/cmd/thanos/downsample.go +++ b/cmd/thanos/downsample.go @@ -6,6 +6,15 @@ import ( "path/filepath" "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "github.com/oklog/run" + "github.com/oklog/ulid" + opentracing "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/prometheus/tsdb" + "github.com/prometheus/prometheus/tsdb/chunkenc" "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/compact" @@ -17,16 +26,6 @@ import ( "github.com/thanos-io/thanos/pkg/prober" "github.com/thanos-io/thanos/pkg/runutil" httpserver "github.com/thanos-io/thanos/pkg/server/http" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/oklog/run" - "github.com/oklog/ulid" - opentracing "github.com/opentracing/opentracing-go" - "github.com/pkg/errors" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/prometheus/tsdb" - "github.com/prometheus/prometheus/tsdb/chunkenc" kingpin "gopkg.in/alecthomas/kingpin.v2" ) diff --git a/cmd/thanos/flags.go b/cmd/thanos/flags.go index 853d153102..b6d7776086 100644 --- a/cmd/thanos/flags.go +++ b/cmd/thanos/flags.go @@ -26,7 +26,7 @@ func regGRPCFlags(cmd *kingpin.CmdClause) ( ) { grpcBindAddr = cmd.Flag("grpc-address", "Listen ip:port address for gRPC endpoints (StoreAPI). Make sure this address is routable from other components."). Default("0.0.0.0:10901").String() - grpcGracePeriod = modelDuration(cmd.Flag("grpc-grace-period", "Time to wait after an interrupt received for GRPC Server.").Default("5s")) + grpcGracePeriod = modelDuration(cmd.Flag("grpc-grace-period", "Time to wait after an interrupt received for GRPC Server.").Default("2m")) // by default it's the same as query.timeout. grpcTLSSrvCert = cmd.Flag("grpc-server-tls-cert", "TLS Certificate for gRPC server, leave blank to disable TLS").Default("").String() grpcTLSSrvKey = cmd.Flag("grpc-server-tls-key", "TLS Key for the gRPC server, leave blank to disable TLS").Default("").String() @@ -41,7 +41,7 @@ func regGRPCFlags(cmd *kingpin.CmdClause) ( func regHTTPFlags(cmd *kingpin.CmdClause) (httpBindAddr *string, httpGracePeriod *model.Duration) { httpBindAddr = cmd.Flag("http-address", "Listen host:port for HTTP endpoints.").Default("0.0.0.0:10902").String() - httpGracePeriod = modelDuration(cmd.Flag("http-grace-period", "Time to wait after an interrupt received for HTTP Server.").Default("5s")) + httpGracePeriod = modelDuration(cmd.Flag("http-grace-period", "Time to wait after an interrupt received for HTTP Server.").Default("2m")) // by default it's the same as query.timeout. return httpBindAddr, httpGracePeriod } diff --git a/cmd/thanos/query.go b/cmd/thanos/query.go index 1edcd79afd..0be1e769b0 100644 --- a/cmd/thanos/query.go +++ b/cmd/thanos/query.go @@ -8,6 +8,19 @@ import ( "path" "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" + grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" + "github.com/oklog/run" + opentracing "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/route" + "github.com/prometheus/prometheus/discovery/file" + "github.com/prometheus/prometheus/discovery/targetgroup" + "github.com/prometheus/prometheus/promql" + "github.com/prometheus/prometheus/tsdb/labels" "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/discovery/cache" "github.com/thanos-io/thanos/pkg/discovery/dns" @@ -23,20 +36,6 @@ import ( "github.com/thanos-io/thanos/pkg/tls" "github.com/thanos-io/thanos/pkg/tracing" "github.com/thanos-io/thanos/pkg/ui" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" - grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" - "github.com/oklog/run" - opentracing "github.com/opentracing/opentracing-go" - "github.com/pkg/errors" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/route" - "github.com/prometheus/prometheus/discovery/file" - "github.com/prometheus/prometheus/discovery/targetgroup" - "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/tsdb/labels" "google.golang.org/grpc" "google.golang.org/grpc/credentials" kingpin "gopkg.in/alecthomas/kingpin.v2" diff --git a/cmd/thanos/receive.go b/cmd/thanos/receive.go index 1f1117828d..1424a13506 100644 --- a/cmd/thanos/receive.go +++ b/cmd/thanos/receive.go @@ -7,6 +7,15 @@ import ( "strings" "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "github.com/oklog/run" + opentracing "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/storage/tsdb" + "github.com/prometheus/prometheus/tsdb/labels" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/extflag" @@ -19,16 +28,6 @@ import ( "github.com/thanos-io/thanos/pkg/shipper" "github.com/thanos-io/thanos/pkg/store" "github.com/thanos-io/thanos/pkg/tls" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/oklog/run" - opentracing "github.com/opentracing/opentracing-go" - "github.com/pkg/errors" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/model" - "github.com/prometheus/prometheus/storage/tsdb" - "github.com/prometheus/prometheus/tsdb/labels" kingpin "gopkg.in/alecthomas/kingpin.v2" ) diff --git a/cmd/thanos/rule.go b/cmd/thanos/rule.go index 3262568062..3d0345b2b0 100644 --- a/cmd/thanos/rule.go +++ b/cmd/thanos/rule.go @@ -17,6 +17,22 @@ import ( "syscall" "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "github.com/oklog/run" + "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/model" + "github.com/prometheus/common/route" + "github.com/prometheus/prometheus/discovery/file" + "github.com/prometheus/prometheus/discovery/targetgroup" + promlabels "github.com/prometheus/prometheus/pkg/labels" + "github.com/prometheus/prometheus/promql" + "github.com/prometheus/prometheus/rules" + "github.com/prometheus/prometheus/storage/tsdb" + "github.com/prometheus/prometheus/tsdb/labels" + "github.com/prometheus/prometheus/util/strutil" "github.com/thanos-io/thanos/pkg/alert" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/component" @@ -39,23 +55,6 @@ import ( "github.com/thanos-io/thanos/pkg/tls" "github.com/thanos-io/thanos/pkg/tracing" "github.com/thanos-io/thanos/pkg/ui" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/oklog/run" - "github.com/opentracing/opentracing-go" - "github.com/pkg/errors" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/model" - "github.com/prometheus/common/route" - "github.com/prometheus/prometheus/discovery/file" - "github.com/prometheus/prometheus/discovery/targetgroup" - promlabels "github.com/prometheus/prometheus/pkg/labels" - "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/rules" - "github.com/prometheus/prometheus/storage/tsdb" - "github.com/prometheus/prometheus/tsdb/labels" - "github.com/prometheus/prometheus/util/strutil" "gopkg.in/alecthomas/kingpin.v2" ) @@ -521,6 +520,7 @@ func runRule( statusProber.SetReady() return s.ListenAndServe() }, func(err error) { + statusProber.SetNotReady(err) s.Shutdown(err) }) } diff --git a/cmd/thanos/sidecar.go b/cmd/thanos/sidecar.go index 062e755fca..437e729f69 100644 --- a/cmd/thanos/sidecar.go +++ b/cmd/thanos/sidecar.go @@ -7,6 +7,14 @@ import ( "sync" "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "github.com/oklog/run" + "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/common/model" + "github.com/prometheus/prometheus/tsdb/labels" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/extflag" @@ -22,15 +30,6 @@ import ( "github.com/thanos-io/thanos/pkg/store" "github.com/thanos-io/thanos/pkg/store/storepb" "github.com/thanos-io/thanos/pkg/tls" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/oklog/run" - "github.com/opentracing/opentracing-go" - "github.com/pkg/errors" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/model" - "github.com/prometheus/prometheus/tsdb/labels" "gopkg.in/alecthomas/kingpin.v2" ) @@ -248,8 +247,10 @@ func runSidecar( grpcserver.WithTLSConfig(tlsCfg), ) g.Add(func() error { + statusProber.SetReady() return s.ListenAndServe() }, func(err error) { + statusProber.SetNotReady(err) s.Shutdown(err) }) } diff --git a/cmd/thanos/store.go b/cmd/thanos/store.go index 4fdceff09b..13833a3a12 100644 --- a/cmd/thanos/store.go +++ b/cmd/thanos/store.go @@ -4,6 +4,13 @@ import ( "context" "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "github.com/oklog/run" + "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/prometheus/pkg/relabel" "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/extflag" "github.com/thanos-io/thanos/pkg/model" @@ -15,14 +22,6 @@ import ( "github.com/thanos-io/thanos/pkg/store" storecache "github.com/thanos-io/thanos/pkg/store/cache" "github.com/thanos-io/thanos/pkg/tls" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/oklog/run" - "github.com/opentracing/opentracing-go" - "github.com/pkg/errors" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/prometheus/pkg/relabel" "gopkg.in/alecthomas/kingpin.v2" yaml "gopkg.in/yaml.v2" ) diff --git a/docs/components/compact.md b/docs/components/compact.md index df1056f571..4a710a6773 100644 --- a/docs/components/compact.md +++ b/docs/components/compact.md @@ -84,7 +84,7 @@ Flags: https://thanos.io/tracing.md/#configuration --http-address="0.0.0.0:10902" Listen host:port for HTTP endpoints. - --http-grace-period=5s Time to wait after an interrupt received for HTTP + --http-grace-period=2m Time to wait after an interrupt received for HTTP Server. --data-dir="./data" Data directory in which to cache blocks and process compactions. diff --git a/docs/components/query.md b/docs/components/query.md index 2ee36af485..2f0a29771f 100644 --- a/docs/components/query.md +++ b/docs/components/query.md @@ -259,13 +259,13 @@ Flags: https://thanos.io/tracing.md/#configuration --http-address="0.0.0.0:10902" Listen host:port for HTTP endpoints. - --http-grace-period=5s Time to wait after an interrupt received for + --http-grace-period=2m Time to wait after an interrupt received for HTTP Server. --grpc-address="0.0.0.0:10901" Listen ip:port address for gRPC endpoints (StoreAPI). Make sure this address is routable from other components. - --grpc-grace-period=5s Time to wait after an interrupt received for + --grpc-grace-period=2m Time to wait after an interrupt received for GRPC Server. --grpc-server-tls-cert="" TLS Certificate for gRPC server, leave blank to disable TLS diff --git a/docs/components/rule.md b/docs/components/rule.md index ded32d5e5a..55bac66749 100644 --- a/docs/components/rule.md +++ b/docs/components/rule.md @@ -168,13 +168,13 @@ Flags: https://thanos.io/tracing.md/#configuration --http-address="0.0.0.0:10902" Listen host:port for HTTP endpoints. - --http-grace-period=5s Time to wait after an interrupt received for + --http-grace-period=2m Time to wait after an interrupt received for HTTP Server. --grpc-address="0.0.0.0:10901" Listen ip:port address for gRPC endpoints (StoreAPI). Make sure this address is routable from other components. - --grpc-grace-period=5s Time to wait after an interrupt received for + --grpc-grace-period=2m Time to wait after an interrupt received for GRPC Server. --grpc-server-tls-cert="" TLS Certificate for gRPC server, leave blank to disable TLS diff --git a/docs/components/sidecar.md b/docs/components/sidecar.md index e2bb2b4358..4dfc4282b2 100644 --- a/docs/components/sidecar.md +++ b/docs/components/sidecar.md @@ -101,13 +101,13 @@ Flags: https://thanos.io/tracing.md/#configuration --http-address="0.0.0.0:10902" Listen host:port for HTTP endpoints. - --http-grace-period=5s Time to wait after an interrupt received for + --http-grace-period=2m Time to wait after an interrupt received for HTTP Server. --grpc-address="0.0.0.0:10901" Listen ip:port address for gRPC endpoints (StoreAPI). Make sure this address is routable from other components. - --grpc-grace-period=5s Time to wait after an interrupt received for + --grpc-grace-period=2m Time to wait after an interrupt received for GRPC Server. --grpc-server-tls-cert="" TLS Certificate for gRPC server, leave blank to disable TLS diff --git a/docs/components/store.md b/docs/components/store.md index 1f08699158..3b2a7f5737 100644 --- a/docs/components/store.md +++ b/docs/components/store.md @@ -51,13 +51,13 @@ Flags: https://thanos.io/tracing.md/#configuration --http-address="0.0.0.0:10902" Listen host:port for HTTP endpoints. - --http-grace-period=5s Time to wait after an interrupt received for + --http-grace-period=2m Time to wait after an interrupt received for HTTP Server. --grpc-address="0.0.0.0:10901" Listen ip:port address for gRPC endpoints (StoreAPI). Make sure this address is routable from other components. - --grpc-grace-period=5s Time to wait after an interrupt received for + --grpc-grace-period=2m Time to wait after an interrupt received for GRPC Server. --grpc-server-tls-cert="" TLS Certificate for gRPC server, leave blank to disable TLS diff --git a/go.mod b/go.mod index 62b62543c4..454676ed2b 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,7 @@ require ( github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v1.2.1 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 - github.com/prometheus/common v0.6.0 + github.com/prometheus/common v0.7.0 github.com/prometheus/prometheus v1.8.2-0.20190913102521-8ab628b35467 // v1.8.2 is misleading as Prometheus does not have v2 module. github.com/uber-go/atomic v1.4.0 // indirect github.com/uber/jaeger-client-go v2.16.0+incompatible @@ -49,7 +49,6 @@ require ( golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582 // indirect golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/sync v0.0.0-20190423024810-112230192c58 - golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect golang.org/x/text v0.3.2 google.golang.org/api v0.11.0 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 diff --git a/go.sum b/go.sum index f57134141b..2ec5b5a3cd 100644 --- a/go.sum +++ b/go.sum @@ -64,6 +64,7 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash v0.0.0-20181017004759-096ff4a8a059/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA= github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= @@ -402,6 +403,7 @@ github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= +github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -410,6 +412,7 @@ github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNG github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/prometheus v0.0.0-20180315085919-58e2a31db8de/go.mod h1:oAIUtOny2rjMX0OWN5vPR5/q/twIROJvdqnQKDdil/s= github.com/prometheus/prometheus v1.8.2-0.20190913102521-8ab628b35467 h1:B9IMa7s163/ZDSduepHHfOZZHSKdSbgo/bFY5c+FMAs= diff --git a/pkg/server/grpc/grpc.go b/pkg/server/grpc/grpc.go index 521bbc39f1..29774485eb 100644 --- a/pkg/server/grpc/grpc.go +++ b/pkg/server/grpc/grpc.go @@ -5,12 +5,6 @@ import ( "math" "net" "runtime/debug" - "time" - - "github.com/pkg/errors" - "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/store/storepb" - "github.com/thanos-io/thanos/pkg/tracing" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" @@ -18,7 +12,11 @@ import ( grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" "github.com/opentracing/opentracing-go" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" + "github.com/thanos-io/thanos/pkg/component" + "github.com/thanos-io/thanos/pkg/store/storepb" + "github.com/thanos-io/thanos/pkg/tracing" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" @@ -38,10 +36,7 @@ type Server struct { // New creates a new Server. func New(logger log.Logger, reg prometheus.Registerer, tracer opentracing.Tracer, comp component.Component, storeSrv storepb.StoreServer, opts ...Option) *Server { - options := options{ - gracePeriod: 5 * time.Second, - } - + options := options{} for _, o := range opts { o.apply(&options) } diff --git a/pkg/server/http/http.go b/pkg/server/http/http.go index 84b65480b3..290d97c59a 100644 --- a/pkg/server/http/http.go +++ b/pkg/server/http/http.go @@ -4,16 +4,14 @@ import ( "context" "net/http" "net/http/pprof" - "time" - - "github.com/thanos-io/thanos/pkg/component" - "github.com/thanos-io/thanos/pkg/prober" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" + "github.com/thanos-io/thanos/pkg/component" + "github.com/thanos-io/thanos/pkg/prober" ) // A Server defines parameters for serve HTTP requests, a wrapper around http.Server. @@ -30,11 +28,7 @@ type Server struct { // New creates a new Server. func New(logger log.Logger, reg *prometheus.Registry, comp component.Component, prober *prober.Prober, opts ...Option) *Server { - options := options{ - gracePeriod: 5 * time.Second, - listen: "0.0.0.0:10902", - } - + options := options{} for _, o := range opts { o.apply(&options) } @@ -72,7 +66,7 @@ func (s *Server) Shutdown(err error) { return } - defer level.Info(s.logger).Log("msg", "internal server shutdown") + defer level.Info(s.logger).Log("msg", "internal server shutdown", "err", err) if s.opts.gracePeriod == 0 { s.srv.Close() diff --git a/pkg/ui/bucket.go b/pkg/ui/bucket.go index 84dfdbfdb5..f1fdd8ee47 100644 --- a/pkg/ui/bucket.go +++ b/pkg/ui/bucket.go @@ -7,7 +7,7 @@ import ( "github.com/go-kit/kit/log" extpromhttp "github.com/thanos-io/thanos/pkg/extprom/http" - "github.com/thanos-io/thanos/pkg/server" + httpserver "github.com/thanos-io/thanos/pkg/server/http" ) // Bucket is a web UI representing state of buckets as a timeline. @@ -30,7 +30,7 @@ func NewBucketUI(logger log.Logger, label string) *Bucket { } // Register registers http routes for bucket UI. -func (b *Bucket) Register(s server.Server, ins extpromhttp.InstrumentationMiddleware) { +func (b *Bucket) Register(s *httpserver.Server, ins extpromhttp.InstrumentationMiddleware) { instrf := func(name string, next func(w http.ResponseWriter, r *http.Request)) http.HandlerFunc { return ins.NewHandler(name, http.HandlerFunc(next)) }