Unified Storage Indexer: Build tenant indexes concurrently (#95795)
* WIP - build tenant indexes concurrently * adds local dev seeders and readme for indexer * update logging and adds locking in getShard() * update logs * Adds Namespaces func. Initializes index after ResourceServer is created. * fixes Count() and updates test lint issues * Initialize index separately. Don't do it when creating the resource server. Makes testing really awkward. * fix lint error * handles error when getting namespaces * updates test and index helper funcs
This commit is contained in:
@@ -2,7 +2,6 @@ package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -51,17 +50,6 @@ func NewResourceServer(ctx context.Context, db infraDB.DB, cfg *setting.Cfg, fea
|
||||
|
||||
if features.IsEnabledGlobally(featuremgmt.FlagUnifiedStorageSearch) {
|
||||
opts.Index = resource.NewResourceIndexServer(cfg, tracer)
|
||||
server, err := resource.NewResourceServer(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// initialze the search index
|
||||
indexer, ok := server.(resource.ResourceIndexer)
|
||||
if !ok {
|
||||
return nil, errors.New("index server does not implement ResourceIndexer")
|
||||
}
|
||||
_, err = indexer.Index(ctx)
|
||||
return server, err
|
||||
}
|
||||
|
||||
if features.IsEnabledGlobally(featuremgmt.FlagKubernetesFolders) {
|
||||
@@ -75,5 +63,18 @@ func NewResourceServer(ctx context.Context, db infraDB.DB, cfg *setting.Cfg, fea
|
||||
}
|
||||
}
|
||||
|
||||
return resource.NewResourceServer(opts)
|
||||
rs, err := resource.NewResourceServer(opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Initialize the indexer if one is configured
|
||||
if opts.Index != nil {
|
||||
_, err = rs.(resource.ResourceIndexer).Index(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return rs, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user