Skip to content

Commit ee02df3

Browse files
committed
Fix panic in lite
lite uses both ingester.Config and distributor.Config. Both of them has IngesterClientConfig, so calling RegisterFlags on them triggers panic. This fix ignores second call to RegisterFlags on IngesterClientConfig and then populates it manually. Was broken in 6191d41
1 parent ff0b6ad commit ee02df3

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

cmd/lite/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func main() {
5757
&ingesterConfig, &configStoreConfig, &rulerConfig, &storageConfig, &schemaConfig, &logLevel)
5858
flag.BoolVar(&unauthenticated, "unauthenticated", false, "Set to true to disable multitenancy.")
5959
flag.Parse()
60+
ingesterConfig.SetClientConfig(distributorConfig.IngesterClientConfig)
6061

6162
// Setting the environment variable JAEGER_AGENT_HOST enables tracing
6263
jaegerAgentHost := os.Getenv("JAEGER_AGENT_HOST")

pkg/ingester/client/client.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package client
22

33
import (
4+
"flag"
5+
46
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
57
"github.com/mwitkow/go-grpc-middleware"
68
"github.com/opentracing/opentracing-go"
9+
"github.com/weaveworks/common/middleware"
710
"google.golang.org/grpc"
811
_ "google.golang.org/grpc/encoding/gzip" // get gzip compressor registered
9-
10-
"flag"
11-
"github.com/weaveworks/common/middleware"
1212
)
1313

1414
type closableIngesterClient struct {
@@ -56,6 +56,12 @@ type Config struct {
5656

5757
// RegisterFlags registers configuration settings used by the ingester client config
5858
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
59+
// lite uses both ingester.Config and distributor.Config.
60+
// Both of them has IngesterClientConfig, so calling RegisterFlags on them triggers panic.
61+
// This check ignores second call to RegisterFlags on IngesterClientConfig and then populates it manually with SetClientConfig
62+
if flag.Lookup("ingester.client.max-recv-message-size") != nil {
63+
return
64+
}
5965
// We have seen 20MB returns from queries - add a bit of headroom
6066
f.IntVar(&cfg.MaxRecvMsgSize, "ingester.client.max-recv-message-size", 64*1024*1024, "Maximum message size, in bytes, this client will receive.")
6167
flag.BoolVar(&cfg.CompressToIngester, "ingester.client.compress-to-ingester", false, "Compress data in calls to ingesters.")

pkg/ingester/ingester.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ type Config struct {
9494
KVClient ring.KVClient
9595
}
9696

97+
// SetClientConfig sets clientConfig in config
98+
func (cfg *Config) SetClientConfig(clientConfig client.Config) {
99+
cfg.clientConfig = clientConfig
100+
}
101+
97102
// RegisterFlags adds the flags required to config this to the given FlagSet
98103
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
99104
cfg.RingConfig.RegisterFlags(f)

0 commit comments

Comments
 (0)