From c1b786c71830560ed20b47bd86d38b932a6f72d2 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Fri, 14 Jun 2024 23:10:59 +0300 Subject: [PATCH] cleanup --- pkg/services/apiserver/service.go | 5 ----- .../store/entity/db/migrations/migrator.go | 12 +--------- pkg/storage/unified/README.md | 22 ++++++++++++------- .../unified/sqlnext}/resource_mig.go | 4 ++-- 4 files changed, 17 insertions(+), 26 deletions(-) rename pkg/{services/store/entity/db/migrations => storage/unified/sqlnext}/resource_mig.go (98%) diff --git a/pkg/services/apiserver/service.go b/pkg/services/apiserver/service.go index 90795d05600..339b52bfd05 100644 --- a/pkg/services/apiserver/service.go +++ b/pkg/services/apiserver/service.go @@ -263,11 +263,6 @@ func (s *service) start(ctx context.Context) error { return err } - err = eDB.Init() - if err != nil { - return err - } - storeServer, err := sqlstash.ProvideSQLEntityServer(eDB, s.tracing) if err != nil { return err diff --git a/pkg/services/store/entity/db/migrations/migrator.go b/pkg/services/store/entity/db/migrations/migrator.go index a6564b38405..78dddd396d1 100644 --- a/pkg/services/store/entity/db/migrations/migrator.go +++ b/pkg/services/store/entity/db/migrations/migrator.go @@ -16,18 +16,8 @@ func MigrateEntityStore(engine *xorm.Engine, cfg *setting.Cfg, features featurem mg := migrator.NewScopedMigrator(engine, cfg, "entity") mg.AddCreateMigration() - initEntityTables(mg) - // Only in development for now!!! When we are ready, we can drop entity and use this - if cfg.Env == setting.Dev { - m2 := migrator.NewScopedMigrator(engine, cfg, "resource") - m2.AddCreateMigration() - initResourceTables(m2) - err := m2.Start(true, 0) - if err != nil { - return err - } - } + initEntityTables(mg) // since it's a new feature enable migration locking by default return mg.Start(true, 0) diff --git a/pkg/storage/unified/README.md b/pkg/storage/unified/README.md index 997bab581aa..cd85de407f8 100644 --- a/pkg/storage/unified/README.md +++ b/pkg/storage/unified/README.md @@ -1,24 +1,30 @@ -This includes three packages +This includes four packages -== resource +## resource this is a go module that can be imported into external projects This includes the protobuf based client+server and all the logic required to convert requests into write events. Protobuf TODO? -- can/should we use upstream k8s proto for query object? -- starting a project today... should we use proto3? +* can/should we use upstream k8s proto for query object? +* starting a project today... should we use proto3? -== apistore +## apistore The apiserver storage.Interface that links the storage to kubernetes -== sqlstash - -SQL based implementation of the unified storage server +Mostly a copy of te +## entitybridge + +Implementes a resource store using the existing entity service. This will let us evolve the +kubernetes interface.Store using existing system structures while we explore better options. +## sqlnext + +VERY early stub exploring alternative sql structure... really just a stub right now + diff --git a/pkg/services/store/entity/db/migrations/resource_mig.go b/pkg/storage/unified/sqlnext/resource_mig.go similarity index 98% rename from pkg/services/store/entity/db/migrations/resource_mig.go rename to pkg/storage/unified/sqlnext/resource_mig.go index c443fdd633a..03152fa2604 100644 --- a/pkg/services/store/entity/db/migrations/resource_mig.go +++ b/pkg/storage/unified/sqlnext/resource_mig.go @@ -1,4 +1,4 @@ -package migrations +package sqlnext import ( "fmt" @@ -6,7 +6,7 @@ import ( "github.com/grafana/grafana/pkg/services/sqlstore/migrator" ) -func initResourceTables(mg *migrator.Migrator) string { +func InitResourceTables(mg *migrator.Migrator) string { marker := "Initialize resource tables (v0)" // changing this key wipe+rewrite everything mg.AddMigration(marker, &migrator.RawSQLMigration{})