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

use tsdb config for initializing index gateway client #6267

Merged
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
4 changes: 3 additions & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,11 @@ func (t *Loki) initTableManager() (services.Service, error) {

func (t *Loki) initStore() (_ services.Service, err error) {
// Always set these configs
// TODO(owen-d): Do the same for TSDB when we add IndexGatewayClientConfig
t.Cfg.StorageConfig.BoltDBShipperConfig.IndexGatewayClientConfig.Mode = t.Cfg.IndexGateway.Mode
t.Cfg.StorageConfig.TSDBShipperConfig.IndexGatewayClientConfig.Mode = t.Cfg.IndexGateway.Mode
if t.Cfg.IndexGateway.Mode == indexgateway.RingMode {
t.Cfg.StorageConfig.BoltDBShipperConfig.IndexGatewayClientConfig.Ring = t.indexGatewayRingManager.Ring
t.Cfg.StorageConfig.TSDBShipperConfig.IndexGatewayClientConfig.Ring = t.indexGatewayRingManager.Ring
}

// If RF > 1 and current or upcoming index type is boltdb-shipper then disable index dedupe and write dedupe cache.
Expand Down Expand Up @@ -894,6 +895,7 @@ func (t *Loki) initIndexGatewayRing() (_ services.Service, err error) {
}

t.Cfg.StorageConfig.BoltDBShipperConfig.Mode = indexshipper.ModeReadOnly
t.Cfg.StorageConfig.TSDBShipperConfig.Mode = indexshipper.ModeReadOnly
t.Cfg.IndexGateway.Ring.ListenPort = t.Cfg.Server.GRPCListenPort

managerMode := indexgateway.ClientMode
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func NewIndexClient(name string, cfg Config, schemaCfg config.SchemaConfig, limi
return boltDBIndexClientWithShipper, nil
}

if shouldUseBoltDBIndexGatewayClient(cfg) {
if shouldUseIndexGatewayClient(cfg.BoltDBShipperConfig.Config) {
gateway, err := gatewayclient.NewGatewayClient(cfg.BoltDBShipperConfig.IndexGatewayClientConfig, registerer, util_log.Logger)
if err != nil {
return nil, err
Expand Down
13 changes: 6 additions & 7 deletions pkg/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,12 @@ func (s *store) chunkClientForPeriod(p config.PeriodConfig) (client.Client, erro
return chunks, nil
}

func shouldUseBoltDBIndexGatewayClient(cfg Config) bool {
if cfg.BoltDBShipperConfig.Mode != indexshipper.ModeReadOnly || cfg.BoltDBShipperConfig.IndexGatewayClientConfig.Disabled {
func shouldUseIndexGatewayClient(cfg indexshipper.Config) bool {
if cfg.Mode != indexshipper.ModeReadOnly || cfg.IndexGatewayClientConfig.Disabled {
return false
}

gatewayCfg := cfg.BoltDBShipperConfig.IndexGatewayClientConfig
gatewayCfg := cfg.IndexGatewayClientConfig
if gatewayCfg.Mode == indexgateway.SimpleMode && gatewayCfg.Address == "" {
return false
}
Expand All @@ -215,10 +215,9 @@ func (s *store) storeForPeriod(p config.PeriodConfig, chunkClient client.Client,
return nil, nil, nil, err
}

// ToDo(Sandeep): Refactor code to not use boltdb-shipper index gateway client config
if shouldUseBoltDBIndexGatewayClient(s.cfg) {
if shouldUseIndexGatewayClient(s.cfg.TSDBShipperConfig) {
// inject the index-gateway client into the index store
gw, err := gatewayclient.NewGatewayClient(s.cfg.BoltDBShipperConfig.IndexGatewayClientConfig, indexClientReg, s.logger)
gw, err := gatewayclient.NewGatewayClient(s.cfg.TSDBShipperConfig.IndexGatewayClientConfig, indexClientReg, s.logger)
if err != nil {
return nil, nil, nil, err
}
Expand Down Expand Up @@ -252,7 +251,7 @@ func (s *store) storeForPeriod(p config.PeriodConfig, chunkClient client.Client,
)

// (Sandeep): Disable IndexGatewayClientStore for stores other than tsdb until we are ready to enable it again
/*if shouldUseBoltDBIndexGatewayClient(s.cfg) {
/*if s.cfg.BoltDBShipperConfig != nil && shouldUseIndexGatewayClient(s.cfg.BoltDBShipperConfig) {
// inject the index-gateway client into the index store
gw, err := shipper.NewGatewayClient(s.cfg.BoltDBShipperConfig.IndexGatewayClientConfig, indexClientReg, s.logger)
if err != nil {
Expand Down