From 13a0e2e4956d76937630508c16d81b58b18d965c Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Wed, 11 Sep 2024 10:28:40 +0200 Subject: [PATCH] Fix panic in initialisation of the bloom planner and builder Signed-off-by: Christian Haudum --- pkg/loki/modules.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index 20d744b0f6201..b22d7315485e5 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -1709,8 +1709,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( @@ -1722,11 +1728,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 @@ -1743,8 +1745,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( @@ -1757,11 +1765,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, ) }