From f09e85c0484250bb3fab30b341e5394b13d2addf Mon Sep 17 00:00:00 2001 From: Will Assis <35489495+gassiss@users.noreply.github.com> Date: Tue, 1 Jul 2025 11:15:10 -0400 Subject: [PATCH] unified-storage: Distributor rename to better reflect that it'll be used for search (#107409) * rename distributor/ring references to "storage-api" to "search-server" --- pkg/modules/dependencies.go | 36 +++++++++---------- pkg/server/module_server.go | 14 ++++---- pkg/server/ring.go | 14 ++++---- ...ibutor.go => search_server_distributor.go} | 8 ++--- ...t.go => search_server_distributor_test.go} | 2 +- ...ibutor.go => search_server_distributor.go} | 8 ++--- 6 files changed, 41 insertions(+), 41 deletions(-) rename pkg/server/{distributor.go => search_server_distributor.go} (63%) rename pkg/server/{distributor_test.go => search_server_distributor_test.go} (99%) rename pkg/storage/unified/resource/{distributor.go => search_server_distributor.go} (95%) diff --git a/pkg/modules/dependencies.go b/pkg/modules/dependencies.go index e413f5248c4..3ffe045ce06 100644 --- a/pkg/modules/dependencies.go +++ b/pkg/modules/dependencies.go @@ -4,25 +4,25 @@ const ( // All includes all modules necessary for Grafana to run as a standalone server All string = "all" - Core string = "core" - MemberlistKV string = "memberlistkv" - GrafanaAPIServer string = "grafana-apiserver" - StorageRing string = "storage-ring" - Distributor string = "distributor" - StorageServer string = "storage-server" - ZanzanaServer string = "zanzana-server" - InstrumentationServer string = "instrumentation-server" - FrontendServer string = "frontend-server" + Core string = "core" + MemberlistKV string = "memberlistkv" + GrafanaAPIServer string = "grafana-apiserver" + SearchServerRing string = "search-server-ring" + SearchServerDistributor string = "search-server-distributor" + StorageServer string = "storage-server" + ZanzanaServer string = "zanzana-server" + InstrumentationServer string = "instrumentation-server" + FrontendServer string = "frontend-server" ) var dependencyMap = map[string][]string{ - MemberlistKV: {InstrumentationServer}, - StorageRing: {InstrumentationServer, MemberlistKV}, - GrafanaAPIServer: {InstrumentationServer}, - StorageServer: {InstrumentationServer, StorageRing}, - ZanzanaServer: {InstrumentationServer}, - Distributor: {InstrumentationServer, MemberlistKV, StorageRing}, - Core: {}, - All: {Core}, - FrontendServer: {}, + MemberlistKV: {InstrumentationServer}, + SearchServerRing: {InstrumentationServer, MemberlistKV}, + GrafanaAPIServer: {InstrumentationServer}, + StorageServer: {InstrumentationServer, SearchServerRing}, + ZanzanaServer: {InstrumentationServer}, + SearchServerDistributor: {InstrumentationServer, MemberlistKV, SearchServerRing}, + Core: {}, + All: {Core}, + FrontendServer: {}, } diff --git a/pkg/server/module_server.go b/pkg/server/module_server.go index 5def1b5c979..979e993eb7a 100644 --- a/pkg/server/module_server.go +++ b/pkg/server/module_server.go @@ -116,10 +116,10 @@ type ModuleServer struct { promGatherer prometheus.Gatherer registerer prometheus.Registerer - MemberlistKVConfig kv.Config - httpServerRouter *mux.Router - storageRing *ring.Ring - storageRingClientPool *ringclient.Pool + MemberlistKVConfig kv.Config + httpServerRouter *mux.Router + searchServerRing *ring.Ring + searchServerRingClientPool *ringclient.Pool } // init initializes the server and its services. @@ -162,8 +162,8 @@ func (s *ModuleServer) Run() error { }) m.RegisterModule(modules.MemberlistKV, s.initMemberlistKV) - m.RegisterModule(modules.StorageRing, s.initRing) - m.RegisterModule(modules.Distributor, s.initDistributor) + m.RegisterModule(modules.SearchServerRing, s.initSearchServerRing) + m.RegisterModule(modules.SearchServerDistributor, s.initSearchServerDistributor) m.RegisterModule(modules.Core, func() (services.Service, error) { return NewService(s.cfg, s.opts, s.apiOpts) @@ -183,7 +183,7 @@ func (s *ModuleServer) Run() error { if err != nil { return nil, err } - return sql.ProvideUnifiedStorageGrpcService(s.cfg, s.features, nil, s.log, s.registerer, docBuilders, s.storageMetrics, s.indexMetrics, s.storageRing, s.MemberlistKVConfig) + return sql.ProvideUnifiedStorageGrpcService(s.cfg, s.features, nil, s.log, s.registerer, docBuilders, s.storageMetrics, s.indexMetrics, s.searchServerRing, s.MemberlistKVConfig) }) m.RegisterModule(modules.ZanzanaServer, func() (services.Service, error) { diff --git a/pkg/server/ring.go b/pkg/server/ring.go index 1499702a81a..cd89f719f8a 100644 --- a/pkg/server/ring.go +++ b/pkg/server/ring.go @@ -25,7 +25,7 @@ import ( var metricsPrefix = resource.RingName + "_" -func (ms *ModuleServer) initRing() (services.Service, error) { +func (ms *ModuleServer) initSearchServerRing() (services.Service, error) { if !ms.cfg.EnableSharding { return nil, nil } @@ -48,7 +48,7 @@ func (ms *ModuleServer) initRing() (services.Service, error) { return nil, fmt.Errorf("failed to create KV store client: %s", err) } - storageRing, err := ring.NewWithStoreClientAndStrategy( + searchServerRing, err := ring.NewWithStoreClientAndStrategy( toRingConfig(ms.cfg, ms.MemberlistKVConfig), resource.RingName, resource.RingKey, @@ -58,11 +58,11 @@ func (ms *ModuleServer) initRing() (services.Service, error) { logger, ) if err != nil { - return nil, fmt.Errorf("failed to initialize storage-ring ring: %s", err) + return nil, fmt.Errorf("failed to initialize index-server-ring ring: %s", err) } startFn := func(ctx context.Context) error { - err = storageRing.StartAsync(ctx) + err = searchServerRing.StartAsync(ctx) if err != nil { return fmt.Errorf("failed to start the ring: %s", err) } @@ -74,10 +74,10 @@ func (ms *ModuleServer) initRing() (services.Service, error) { return nil } - ms.storageRing = storageRing - ms.storageRingClientPool = pool + ms.searchServerRing = searchServerRing + ms.searchServerRingClientPool = pool - ms.httpServerRouter.Path("/ring").Methods("GET", "POST").Handler(storageRing) + ms.httpServerRouter.Path("/ring").Methods("GET", "POST").Handler(searchServerRing) svc := services.NewIdleService(startFn, nil) diff --git a/pkg/server/distributor.go b/pkg/server/search_server_distributor.go similarity index 63% rename from pkg/server/distributor.go rename to pkg/server/search_server_distributor.go index 79306666822..41eaabd8b28 100644 --- a/pkg/server/distributor.go +++ b/pkg/server/search_server_distributor.go @@ -10,18 +10,18 @@ import ( "go.opentelemetry.io/otel" ) -func (ms *ModuleServer) initDistributor() (services.Service, error) { +func (ms *ModuleServer) initSearchServerDistributor() (services.Service, error) { var ( distributor = &distributorService{} - tracer = otel.Tracer("unified-storage-distributor") + tracer = otel.Tracer("index-server-distributor") err error ) - distributor.grpcHandler, err = resource.ProvideDistributorServer(ms.cfg, ms.features, ms.registerer, tracer, ms.storageRing, ms.storageRingClientPool) + distributor.grpcHandler, err = resource.ProvideSearchDistributorServer(ms.cfg, ms.features, ms.registerer, tracer, ms.searchServerRing, ms.searchServerRingClientPool) if err != nil { return nil, err } - return services.NewBasicService(nil, distributor.running, nil).WithName(modules.Distributor), nil + return services.NewBasicService(nil, distributor.running, nil).WithName(modules.SearchServerDistributor), nil } type distributorService struct { diff --git a/pkg/server/distributor_test.go b/pkg/server/search_server_distributor_test.go similarity index 99% rename from pkg/server/distributor_test.go rename to pkg/server/search_server_distributor_test.go index b84c002b756..3062b1efe8d 100644 --- a/pkg/server/distributor_test.go +++ b/pkg/server/search_server_distributor_test.go @@ -273,7 +273,7 @@ func initDistributorServerForTest(t *testing.T, memberlistPort int) testModuleSe cfg.MemberlistJoinMember = "127.0.0.1:" + strconv.Itoa(memberlistPort) cfg.MemberlistAdvertiseAddr = "127.0.0.1" cfg.MemberlistAdvertisePort = memberlistPort - cfg.Target = []string{modules.Distributor} + cfg.Target = []string{modules.SearchServerDistributor} cfg.InstanceID = "distributor" // does nothing for the distributor but may be useful to debug tests conn, err := grpc.NewClient(cfg.GRPCServer.Address, diff --git a/pkg/storage/unified/resource/distributor.go b/pkg/storage/unified/resource/search_server_distributor.go similarity index 95% rename from pkg/storage/unified/resource/distributor.go rename to pkg/storage/unified/resource/search_server_distributor.go index fc49901d255..4fbb7083aca 100644 --- a/pkg/storage/unified/resource/distributor.go +++ b/pkg/storage/unified/resource/search_server_distributor.go @@ -21,7 +21,7 @@ import ( "google.golang.org/grpc/metadata" ) -func ProvideDistributorServer(cfg *setting.Cfg, features featuremgmt.FeatureToggles, registerer prometheus.Registerer, tracer trace.Tracer, ring *ring.Ring, ringClientPool *ringclient.Pool) (grpcserver.Provider, error) { +func ProvideSearchDistributorServer(cfg *setting.Cfg, features featuremgmt.FeatureToggles, registerer prometheus.Registerer, tracer trace.Tracer, ring *ring.Ring, ringClientPool *ringclient.Pool) (grpcserver.Provider, error) { var err error grpcHandler, err := grpcserver.ProvideService(cfg, features, nil, tracer, registerer) if err != nil { @@ -29,7 +29,7 @@ func ProvideDistributorServer(cfg *setting.Cfg, features featuremgmt.FeatureTogg } distributorServer := &distributorServer{ - log: log.New("unified-storage-distributor"), + log: log.New("index-server-distributor"), ring: ring, clientPool: ringClientPool, } @@ -73,8 +73,8 @@ func (c *RingClient) RemoteAddress() string { return c.Conn.Target() } -const RingKey = "unified-storage-ring" -const RingName = "unified_storage_ring" +const RingKey = "search-server-ring" +const RingName = "search_server_ring" const RingHeartbeatTimeout = time.Minute const RingNumTokens = 128