From c6c8c6e928d9a2f9581986492bd2861601979a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20=C5=A0tibran=C3=BD?= Date: Thu, 11 Sep 2025 16:08:41 +0200 Subject: [PATCH] Remove feature toggles from bleve backend. (#110951) * Remove feature toggles from search backend. * Remove extra import. * Remove unnecessary code. --- pkg/storage/unified/search/bleve.go | 7 +------ pkg/storage/unified/search/bleve_integration_test.go | 5 ++--- pkg/storage/unified/search/bleve_search_test.go | 3 +-- pkg/storage/unified/search/bleve_test.go | 5 ++--- pkg/storage/unified/search/options.go | 2 +- pkg/storage/unified/sql/test/integration_test.go | 2 +- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/pkg/storage/unified/search/bleve.go b/pkg/storage/unified/search/bleve.go index 88ddca29ee5..d9c7ac95fc8 100644 --- a/pkg/storage/unified/search/bleve.go +++ b/pkg/storage/unified/search/bleve.go @@ -30,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/selection" "github.com/grafana/grafana/pkg/services/dashboards/dashboardaccess" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/storage/unified/resourcepb" authlib "github.com/grafana/authlib/types" @@ -76,11 +75,10 @@ type bleveBackend struct { cacheMx sync.RWMutex cache map[resource.NamespacedResource]*bleveIndex - features featuremgmt.FeatureToggles indexMetrics *resource.BleveIndexMetrics } -func NewBleveBackend(opts BleveOptions, tracer trace.Tracer, features featuremgmt.FeatureToggles, indexMetrics *resource.BleveIndexMetrics) (*bleveBackend, error) { +func NewBleveBackend(opts BleveOptions, tracer trace.Tracer, indexMetrics *resource.BleveIndexMetrics) (*bleveBackend, error) { if opts.Root == "" { return nil, fmt.Errorf("bleve backend missing root folder configuration") } @@ -108,7 +106,6 @@ func NewBleveBackend(opts BleveOptions, tracer trace.Tracer, features featuremgm tracer: tracer, cache: map[resource.NamespacedResource]*bleveIndex{}, opts: opts, - features: features, indexMetrics: indexMetrics, } @@ -583,7 +580,6 @@ type bleveIndex struct { // The values returned with all allFields []*resourcepb.ResourceTableColumnDefinition - features featuremgmt.FeatureToggles tracing trace.Tracer logger *slog.Logger @@ -617,7 +613,6 @@ func (b *bleveBackend) newBleveIndex( fields: fields, allFields: allFields, standard: standardSearchFields, - features: b.features, tracing: b.tracer, logger: logger, updaterFn: updaterFn, diff --git a/pkg/storage/unified/search/bleve_integration_test.go b/pkg/storage/unified/search/bleve_integration_test.go index 7c3ca33f095..36f19a0bfd3 100644 --- a/pkg/storage/unified/search/bleve_integration_test.go +++ b/pkg/storage/unified/search/bleve_integration_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" "github.com/grafana/grafana/pkg/infra/tracing" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/storage/unified/resource" unitest "github.com/grafana/grafana/pkg/storage/unified/testing" ) @@ -21,7 +20,7 @@ func TestBleveSearchBackend(t *testing.T) { backend, err := NewBleveBackend(BleveOptions{ Root: tempDir, FileThreshold: 5, - }, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(), nil) + }, tracing.NewNoopTracerService(), nil) require.NoError(t, err) require.NotNil(t, backend) @@ -46,7 +45,7 @@ func TestSearchBackendBenchmark(t *testing.T) { // Create a new bleve backend backend, err := NewBleveBackend(BleveOptions{ Root: tempDir, - }, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(), nil) + }, tracing.NewNoopTracerService(), nil) require.NoError(t, err) require.NotNil(t, backend) diff --git a/pkg/storage/unified/search/bleve_search_test.go b/pkg/storage/unified/search/bleve_search_test.go index 250001dc824..6e54f1ded2a 100644 --- a/pkg/storage/unified/search/bleve_search_test.go +++ b/pkg/storage/unified/search/bleve_search_test.go @@ -11,7 +11,6 @@ import ( "github.com/grafana/grafana/pkg/apimachinery/identity" "github.com/grafana/grafana/pkg/infra/tracing" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/store/kind/dashboard" "github.com/grafana/grafana/pkg/services/user" "github.com/grafana/grafana/pkg/storage/unified/resource" @@ -232,7 +231,7 @@ func newTestDashboardsIndex(t testing.TB, threshold int64, size int64, batchSize Root: t.TempDir(), FileThreshold: threshold, // use in-memory for tests BatchSize: int(batchSize), - }, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(), nil) + }, tracing.NewNoopTracerService(), nil) require.NoError(t, err) t.Cleanup(backend.CloseAllIndexes) diff --git a/pkg/storage/unified/search/bleve_test.go b/pkg/storage/unified/search/bleve_test.go index b3c140cbdd6..f270c375e86 100644 --- a/pkg/storage/unified/search/bleve_test.go +++ b/pkg/storage/unified/search/bleve_test.go @@ -28,7 +28,6 @@ import ( "github.com/grafana/grafana/pkg/infra/log/logtest" "github.com/grafana/grafana/pkg/infra/tracing" authzextv1 "github.com/grafana/grafana/pkg/services/authz/proto/v1" - "github.com/grafana/grafana/pkg/services/featuremgmt" "github.com/grafana/grafana/pkg/services/store/kind/dashboard" "github.com/grafana/grafana/pkg/services/user" "github.com/grafana/grafana/pkg/storage/unified/resource" @@ -63,7 +62,7 @@ func TestBleveBackend(t *testing.T) { backend, err := NewBleveBackend(BleveOptions{ Root: tmpdir, FileThreshold: 5, // with more than 5 items we create a file on disk - }, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(), nil) + }, tracing.NewNoopTracerService(), nil) require.NoError(t, err) t.Cleanup(backend.CloseAllIndexes) @@ -769,7 +768,7 @@ func setupBleveBackend(t *testing.T, fileThreshold int, cacheTTL time.Duration, FileThreshold: int64(fileThreshold), IndexCacheTTL: cacheTTL, Logger: slog.New(logtest.NewNopHandler(t)), - }, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(), metrics) + }, tracing.NewNoopTracerService(), metrics) require.NoError(t, err) require.NotNil(t, backend) t.Cleanup(backend.CloseAllIndexes) diff --git a/pkg/storage/unified/search/options.go b/pkg/storage/unified/search/options.go index d261a445a12..b50f68ddf4d 100644 --- a/pkg/storage/unified/search/options.go +++ b/pkg/storage/unified/search/options.go @@ -28,7 +28,7 @@ func NewSearchOptions(features featuremgmt.FeatureToggles, cfg *setting.Cfg, tra FileThreshold: int64(cfg.IndexFileThreshold), // fewer than X items will use a memory index BatchSize: cfg.IndexMaxBatchSize, // This is the batch size for how many objects to add to the index at once IndexCacheTTL: cfg.IndexCacheTTL, // How long to keep the index cache in memory - }, tracer, features, indexMetrics) + }, tracer, indexMetrics) if err != nil { return resource.SearchOptions{}, err diff --git a/pkg/storage/unified/sql/test/integration_test.go b/pkg/storage/unified/sql/test/integration_test.go index a3bcc555e51..99c3d17b77a 100644 --- a/pkg/storage/unified/sql/test/integration_test.go +++ b/pkg/storage/unified/sql/test/integration_test.go @@ -111,7 +111,7 @@ func TestIntegrationSearchAndStorage(t *testing.T) { search, err := search.NewBleveBackend(search.BleveOptions{ FileThreshold: 0, Root: tempDir, - }, tracing.NewNoopTracerService(), featuremgmt.WithFeatures(), nil) + }, tracing.NewNoopTracerService(), nil) require.NoError(t, err) require.NotNil(t, search)