Skip to content

Commit

Permalink
chore: [k219] fix(blooms): Fix panic in initialisation of the bloom p…
Browse files Browse the repository at this point in the history
…lanner and builder (#14114)

Backport 8307c42 from #14110

Co-authored-by: Christian Haudum <[email protected]>
  • Loading branch information
grafanabot and chaudum authored Sep 11, 2024
1 parent 0780456 commit 9d66018
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1708,8 +1708,14 @@ func (t *Loki) initBloomPlanner() (services.Service, error) {

logger := log.With(util_log.Logger, "component", "bloom-planner")

var ringManager *lokiring.RingManager
if t.Cfg.isTarget(Backend) && t.indexGatewayRingManager != nil {
// Bloom planner and builder are part of the backend target in Simple Scalable Deployment mode.
// To avoid creating a new ring just for this special case, we can use the index gateway ring, which is already
// part of the backend target. The planner creates a watcher service that regularly checks which replica is
// the leader. Only the leader plans the tasks. Builders connect to the leader instance to pull tasks.
level.Info(logger).Log("msg", "initializing bloom planner in ring mode as part of backend target")
ringManager = t.indexGatewayRingManager
}

p, err := planner.New(
Expand All @@ -1721,11 +1727,7 @@ func (t *Loki) initBloomPlanner() (services.Service, error) {
t.BloomStore,
logger,
prometheus.DefaultRegisterer,
// Bloom planner and builder are part of the backend target in Simple Scalable Deployment mode.
// To avoid creating a new ring just for this special case, we can use the index gateway ring, which is already
// part of the backend target. The planner creates a watcher service that regularly checks which replica is
// the leader. Only the leader plans the tasks. Builders connect to the leader instance to pull tasks.
t.indexGatewayRingManager,
ringManager,
)
if err != nil {
return nil, err
Expand All @@ -1742,8 +1744,14 @@ func (t *Loki) initBloomBuilder() (services.Service, error) {

logger := log.With(util_log.Logger, "component", "bloom-builder")

var ringManager *lokiring.RingManager
if t.Cfg.isTarget(Backend) && t.indexGatewayRingManager != nil {
// Bloom planner and builder are part of the backend target in Simple Scalable Deployment mode.
// To avoid creating a new ring just for this special case, we can use the index gateway ring, which is already
// part of the backend target. The planner creates a watcher service that regularly checks which replica is
// the leader. Only the leader plans the tasks. Builders connect to the leader instance to pull tasks.
level.Info(logger).Log("msg", "initializing bloom builder in ring mode as part of backend target")
ringManager = t.indexGatewayRingManager
}

return builder.New(
Expand All @@ -1756,11 +1764,7 @@ func (t *Loki) initBloomBuilder() (services.Service, error) {
t.BloomStore,
logger,
prometheus.DefaultRegisterer,
// Bloom planner and builder are part of the backend target in Simple Scalable Deployment mode.
// To avoid creating a new ring just for this special case, we can use the index gateway ring, which is already
// part of the backend target. The planner creates a watcher service that regularly checks which replica is
// the leader. Only the leader plans the tasks. Builders connect to the leader instance to pull tasks.
t.indexGatewayRingManager,
ringManager,
)
}

Expand Down

0 comments on commit 9d66018

Please sign in to comment.