Skip to content

Commit

Permalink
use tsdb config for initializing index gateway client
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepsukhani committed May 30, 2022
1 parent 9b2786b commit 5031e3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
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 shouldUseIndexGatewayClient(s.cfg) {
// 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

0 comments on commit 5031e3f

Please sign in to comment.