diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index 2396e6a6ad7..3e803ad3555 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -105,7 +105,7 @@ The following toggles require explicitly setting Grafana's [app mode]({{< relref | `export` | Export grafana instance (to git, etc) | | `azureMonitorResourcePickerForMetrics` | New UI for Azure Monitor Metrics Query | | `grpcServer` | Run GRPC server | -| `objectStore` | SQL-based object store | +| `entityStore` | SQL-based entity store (requires storage flag also) | | `queryLibrary` | Reusable query library | | `accessControlOnCall` | Access control primitives for OnCall | | `nestedFolders` | Enable folder nesting | diff --git a/go.mod b/go.mod index 49237225464..16fb97f6a2f 100644 --- a/go.mod +++ b/go.mod @@ -203,7 +203,7 @@ require ( github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect github.com/oklog/run v1.1.0 // indirect github.com/oklog/ulid v1.3.1 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/olekukonko/tablewriter v0.0.5 github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index e57ca1881ea..7276ab8d74a 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -65,7 +65,7 @@ export interface FeatureToggles { internationalization?: boolean; topnav?: boolean; grpcServer?: boolean; - objectStore?: boolean; + entityStore?: boolean; traceqlEditor?: boolean; flameGraph?: boolean; cloudWatchCrossAccountQuerying?: boolean; diff --git a/pkg/api/api.go b/pkg/api/api.go index 53f37b502f7..75d9cf3b763 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -285,11 +285,11 @@ func (hs *HTTPServer) registerRoutes() { if hs.Features.IsEnabled(featuremgmt.FlagStorage) { // Will eventually be replaced with the 'object' route apiRoute.Group("/storage", hs.StorageService.RegisterHTTPRoutes) + } - // Allow HTTP access to the object storage feature (dev only for now) - if hs.Features.IsEnabled(featuremgmt.FlagGrpcServer) { - apiRoute.Group("/object", hs.httpEntityStore.RegisterHTTPRoutes) - } + // Allow HTTP access to the entity storage feature (dev only for now) + if hs.Features.IsEnabled(featuremgmt.FlagEntityStore) { + apiRoute.Group("/entity", hs.httpEntityStore.RegisterHTTPRoutes) } if hs.Features.IsEnabled(featuremgmt.FlagPanelTitleSearch) { diff --git a/pkg/services/export/service.go b/pkg/services/export/service.go index f54e10d4b76..a1e7950e784 100644 --- a/pkg/services/export/service.go +++ b/pkg/services/export/service.go @@ -233,7 +233,7 @@ func (ex *StandardExport) HandleRequestExport(c *models.ReqContext) response.Res switch cfg.Format { case "dummy": job, err = startDummyExportJob(cfg, broadcast) - case "objectStore": + case "entityStore": job, err = startEntityStoreJob(ctx, cfg, broadcast, ex.db, ex.playlistService, ex.store, ex.dashboardsnapshotsService) case "git": dir := filepath.Join(ex.dataDir, "export_git", fmt.Sprintf("git_%d", time.Now().Unix())) diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 7c31799169b..6528068dcfd 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -281,8 +281,8 @@ var ( RequiresDevMode: true, }, { - Name: "objectStore", - Description: "SQL-based object store", + Name: "entityStore", + Description: "SQL-based entity store (requires storage flag also)", State: FeatureStateAlpha, RequiresDevMode: true, }, diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 7e4d36b5c3e..06c778de072 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -203,9 +203,9 @@ const ( // Run GRPC server FlagGrpcServer = "grpcServer" - // FlagObjectStore - // SQL-based object store - FlagObjectStore = "objectStore" + // FlagEntityStore + // SQL-based entity store (requires storage flag also) + FlagEntityStore = "entityStore" // FlagTraceqlEditor // Show the TraceQL editor in the explore page diff --git a/pkg/services/playlist/playlistimpl/object_store.go b/pkg/services/playlist/playlistimpl/entity_store.go similarity index 81% rename from pkg/services/playlist/playlistimpl/object_store.go rename to pkg/services/playlist/playlistimpl/entity_store.go index 5e67883943b..43d0848f89b 100644 --- a/pkg/services/playlist/playlistimpl/object_store.go +++ b/pkg/services/playlist/playlistimpl/entity_store.go @@ -18,15 +18,15 @@ import ( // 2. CREATE/UPDATE/DELETE same items to the object store // 3. Use the object store for all read operations // This givs us a safe test bed to work with the store but still roll back without any lost work -type objectStoreImpl struct { - sess *session.SessionDB - sqlimpl *Service - objectstore entity.EntityStoreServer +type entityStoreImpl struct { + sess *session.SessionDB + sqlimpl *Service + store entity.EntityStoreServer } -var _ playlist.Service = &objectStoreImpl{} +var _ playlist.Service = &entityStoreImpl{} -func (s *objectStoreImpl) sync() { +func (s *entityStoreImpl) sync() { type Info struct { OrgID int64 `db:"org_id"` UID string `db:"uid"` @@ -55,7 +55,7 @@ func (s *objectStoreImpl) sync() { return } body, _ := json.Marshal(dto) - _, _ = s.objectstore.Write(ctx, &entity.WriteEntityRequest{ + _, _ = s.store.Write(ctx, &entity.WriteEntityRequest{ GRN: &entity.GRN{ TenantId: info.OrgID, UID: info.UID, @@ -66,14 +66,14 @@ func (s *objectStoreImpl) sync() { } } -func (s *objectStoreImpl) Create(ctx context.Context, cmd *playlist.CreatePlaylistCommand) (*playlist.Playlist, error) { +func (s *entityStoreImpl) Create(ctx context.Context, cmd *playlist.CreatePlaylistCommand) (*playlist.Playlist, error) { rsp, err := s.sqlimpl.store.Insert(ctx, cmd) if err == nil && rsp != nil { body, err := json.Marshal(cmd) if err != nil { return rsp, fmt.Errorf("unable to write playlist to store") } - _, err = s.objectstore.Write(ctx, &entity.WriteEntityRequest{ + _, err = s.store.Write(ctx, &entity.WriteEntityRequest{ GRN: &entity.GRN{ Kind: models.StandardKindPlaylist, UID: rsp.UID, @@ -87,14 +87,14 @@ func (s *objectStoreImpl) Create(ctx context.Context, cmd *playlist.CreatePlayli return rsp, err } -func (s *objectStoreImpl) Update(ctx context.Context, cmd *playlist.UpdatePlaylistCommand) (*playlist.PlaylistDTO, error) { +func (s *entityStoreImpl) Update(ctx context.Context, cmd *playlist.UpdatePlaylistCommand) (*playlist.PlaylistDTO, error) { rsp, err := s.sqlimpl.store.Update(ctx, cmd) if err == nil { body, err := json.Marshal(cmd) if err != nil { return rsp, fmt.Errorf("unable to write playlist to store") } - _, err = s.objectstore.Write(ctx, &entity.WriteEntityRequest{ + _, err = s.store.Write(ctx, &entity.WriteEntityRequest{ GRN: &entity.GRN{ UID: rsp.Uid, Kind: models.StandardKindPlaylist, @@ -108,10 +108,10 @@ func (s *objectStoreImpl) Update(ctx context.Context, cmd *playlist.UpdatePlayli return rsp, err } -func (s *objectStoreImpl) Delete(ctx context.Context, cmd *playlist.DeletePlaylistCommand) error { +func (s *entityStoreImpl) Delete(ctx context.Context, cmd *playlist.DeletePlaylistCommand) error { err := s.sqlimpl.store.Delete(ctx, cmd) if err == nil { - _, err = s.objectstore.Delete(ctx, &entity.DeleteEntityRequest{ + _, err = s.store.Delete(ctx, &entity.DeleteEntityRequest{ GRN: &entity.GRN{ UID: cmd.UID, Kind: models.StandardKindPlaylist, @@ -128,7 +128,7 @@ func (s *objectStoreImpl) Delete(ctx context.Context, cmd *playlist.DeletePlayli // Read access is managed entirely by the object store //------------------------------------------------------ -func (s *objectStoreImpl) GetWithoutItems(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.Playlist, error) { +func (s *entityStoreImpl) GetWithoutItems(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.Playlist, error) { p, err := s.Get(ctx, q) // OrgID is actually picked from the user! if err != nil { return nil, err @@ -141,8 +141,8 @@ func (s *objectStoreImpl) GetWithoutItems(ctx context.Context, q *playlist.GetPl }, nil } -func (s *objectStoreImpl) Get(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.PlaylistDTO, error) { - rsp, err := s.objectstore.Read(ctx, &entity.ReadEntityRequest{ +func (s *entityStoreImpl) Get(ctx context.Context, q *playlist.GetPlaylistByUidQuery) (*playlist.PlaylistDTO, error) { + rsp, err := s.store.Read(ctx, &entity.ReadEntityRequest{ GRN: &entity.GRN{ UID: q.UID, Kind: models.StandardKindPlaylist, @@ -162,10 +162,10 @@ func (s *objectStoreImpl) Get(ctx context.Context, q *playlist.GetPlaylistByUidQ return found, err } -func (s *objectStoreImpl) Search(ctx context.Context, q *playlist.GetPlaylistsQuery) (playlist.Playlists, error) { +func (s *entityStoreImpl) Search(ctx context.Context, q *playlist.GetPlaylistsQuery) (playlist.Playlists, error) { playlists := make(playlist.Playlists, 0) - rsp, err := s.objectstore.Search(ctx, &entity.EntitySearchRequest{ + rsp, err := s.store.Search(ctx, &entity.EntitySearchRequest{ Kind: []string{models.StandardKindPlaylist}, WithBody: true, Limit: 1000, diff --git a/pkg/services/playlist/playlistimpl/playlist.go b/pkg/services/playlist/playlistimpl/playlist.go index 6162b45235b..79f092c127c 100644 --- a/pkg/services/playlist/playlistimpl/playlist.go +++ b/pkg/services/playlist/playlistimpl/playlist.go @@ -31,11 +31,11 @@ func ProvideService(db db.DB, toggles featuremgmt.FeatureToggles, objserver enti svc := &Service{store: sqlstore} // FlagObjectStore is only supported in development mode - if toggles.IsEnabled(featuremgmt.FlagObjectStore) { - impl := &objectStoreImpl{ - sqlimpl: svc, - objectstore: objserver, - sess: db.GetSqlxSession(), + if toggles.IsEnabled(featuremgmt.FlagEntityStore) { + impl := &entityStoreImpl{ + sqlimpl: svc, + store: objserver, + sess: db.GetSqlxSession(), } impl.sync() // load everythign from the existing SQL setup into the new object store return impl diff --git a/pkg/services/sqlstore/migrations/object_store_mig.go b/pkg/services/sqlstore/migrations/entity_store_mig.go similarity index 99% rename from pkg/services/sqlstore/migrations/object_store_mig.go rename to pkg/services/sqlstore/migrations/entity_store_mig.go index b05d91ea9b7..baa40ee41d0 100644 --- a/pkg/services/sqlstore/migrations/object_store_mig.go +++ b/pkg/services/sqlstore/migrations/entity_store_mig.go @@ -18,7 +18,7 @@ func getLatinPathColumn(name string) *migrator.Column { } } -func addObjectStorageMigrations(mg *migrator.Migrator) { +func addEntityStoreMigrations(mg *migrator.Migrator) { grnLength := 256 // len(tenant)~8 + len(kind)!16 + len(kind)~128 = 256 tables := []migrator.Table{} tables = append(tables, migrator.Table{ diff --git a/pkg/services/sqlstore/migrations/migrations.go b/pkg/services/sqlstore/migrations/migrations.go index f0689a581c0..30b08f96067 100644 --- a/pkg/services/sqlstore/migrations/migrations.go +++ b/pkg/services/sqlstore/migrations/migrations.go @@ -83,8 +83,8 @@ func (*OSSMigrations) AddMigration(mg *Migrator) { addCommentMigrations(mg) } - if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagObjectStore) { - addObjectStorageMigrations(mg) + if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagEntityStore) { + addEntityStoreMigrations(mg) } } diff --git a/pkg/services/sqlstore/sqlstore.go b/pkg/services/sqlstore/sqlstore.go index 411c30d038b..be59253c184 100644 --- a/pkg/services/sqlstore/sqlstore.go +++ b/pkg/services/sqlstore/sqlstore.go @@ -489,7 +489,7 @@ var featuresEnabledDuringTests = []string{ featuremgmt.FlagDashboardPreviews, featuremgmt.FlagDashboardComments, featuremgmt.FlagPanelTitleSearch, - featuremgmt.FlagObjectStore, + featuremgmt.FlagEntityStore, } // InitTestDBWithMigration initializes the test DB given custom migrations. diff --git a/pkg/services/store/entity/json.go b/pkg/services/store/entity/json.go index 37266d8727f..34933e7dec9 100644 --- a/pkg/services/store/entity/json.go +++ b/pkg/services/store/entity/json.go @@ -11,7 +11,7 @@ import ( func init() { //nolint:gochecknoinits jsoniter.RegisterTypeEncoder("entity.EntitySearchResult", &searchResultCodec{}) - jsoniter.RegisterTypeEncoder("entity.WriteObjectResponse", &writeResponseCodec{}) + jsoniter.RegisterTypeEncoder("entity.WriteEntityResponse", &writeResponseCodec{}) jsoniter.RegisterTypeEncoder("entity.ReadEntityResponse", &readResponseCodec{}) jsoniter.RegisterTypeEncoder("entity.Entity", &rawEntityCodec{}) diff --git a/pkg/services/store/entity/tests/common.go b/pkg/services/store/entity/tests/common.go index 476fde75312..78628eccbaf 100644 --- a/pkg/services/store/entity/tests/common.go +++ b/pkg/services/store/entity/tests/common.go @@ -64,7 +64,7 @@ func createTestContext(t *testing.T) testContext { dir, path := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{ EnableFeatureToggles: []string{ featuremgmt.FlagGrpcServer, - featuremgmt.FlagObjectStore, + featuremgmt.FlagEntityStore, }, AppModeProduction: false, // required for migrations to run GRPCServerAddress: "127.0.0.1:0", // :0 for choosing the port automatically diff --git a/public/app/features/storage/ExportView.tsx b/public/app/features/storage/ExportView.tsx index aa9ee5180fb..73827a3e7bc 100644 --- a/public/app/features/storage/ExportView.tsx +++ b/public/app/features/storage/ExportView.tsx @@ -61,7 +61,7 @@ interface ExporterInfo { const formats: Array> = [ { label: 'GIT', value: 'git', description: 'Exports a fresh git repository' }, - { label: 'Object store', value: 'objectStore', description: 'Export to the SQL based object store' }, + { label: 'Entity store', value: 'entityStore', description: 'Export to the SQL based entity store' }, ]; interface Props { @@ -173,9 +173,9 @@ export const ExportView = ({ onPathChange }: Props) => { onChange={(v) => setBody({ ...body!, format: v.value! })} /> - {body?.format === 'objectStore' && !config.featureToggles.objectStore && ( + {body?.format === 'entityStore' && !config.featureToggles.entityStore && (
- Enable the `objectStore` feature flag + Enable the `entityStore` feature flag
)} {body?.format === 'git' && (