Skip to content

Commit

Permalink
Validate config
Browse files Browse the repository at this point in the history
  • Loading branch information
salvacorts committed Dec 5, 2023
1 parent 859de06 commit cdad32d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/bloomgateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ func (i *ClientConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.BoolVar(&i.LogGatewayRequests, prefix+"log-gateway-requests", false, "Flag to control whether requests sent to the gateway should be logged or not.")
}

func (i *ClientConfig) Validate() error {
if err := i.GRPCClientConfig.Validate(); err != nil {
return errors.Wrap(err, "grpc client config")
}

if i.CacheResults {
if err := i.Cache.Validate(); err != nil {
return errors.Wrap(err, "cache config")
}
}

return nil
}

type Client interface {
FilterChunks(ctx context.Context, tenant string, from, through model.Time, groups []*logproto.GroupedChunkRefs, filters ...*logproto.LineFilterExpression) ([]*logproto.GroupedChunkRefs, error)
}
Expand Down Expand Up @@ -156,10 +170,6 @@ func NewGatewayClient(

var c cache.Cache
if cfg.CacheResults {
if !cache.IsCacheConfigured(cfg.Cache.CacheConfig) {
return nil, errors.New("cache is not configured")
}

c, err = cache.New(cfg.Cache.CacheConfig, registerer, logger, stats.BloomFilterCache, constants.Loki)
if err != nil {
return nil, errors.Wrap(err, "new bloom gateway cache")
Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/chunk/cache/resultscache/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func (cfg *Config) Validate() error {
return errors.Errorf("unsupported compression type: %s", cfg.Compression)
}

if !cache.IsCacheConfigured(cfg.CacheConfig) {
return errors.New("no cache configured")
}

return nil
}

Expand Down

0 comments on commit cdad32d

Please sign in to comment.