diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index 1d6e28315000..7b5693d7e6b7 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -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. @@ -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 diff --git a/pkg/storage/factory.go b/pkg/storage/factory.go index 22c4c57bfe27..052b26ebfc2d 100644 --- a/pkg/storage/factory.go +++ b/pkg/storage/factory.go @@ -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 diff --git a/pkg/storage/store.go b/pkg/storage/store.go index 5f78072b230a..b377a390fa0c 100644 --- a/pkg/storage/store.go +++ b/pkg/storage/store.go @@ -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 } @@ -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 } @@ -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 {