From 72790b0614ead6eced65b5266fca5bdc7868b53c Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Fri, 3 Feb 2023 13:21:48 -0800 Subject: [PATCH] Live: Remove dev code that would save config and messages in SQL (#62912) --- .../feature-toggles/index.md | 1 - .../src/types/featureToggles.gen.ts | 1 - pkg/services/export/export_live.go | 50 ------------------- pkg/services/export/service.go | 6 --- pkg/services/featuremgmt/registry.go | 5 -- pkg/services/featuremgmt/toggles_gen.go | 4 -- pkg/services/featuremgmt/toggles_gen_test.go | 1 - pkg/services/live/database/storage.go | 18 ------- pkg/services/sqlstore/migrations/live_mig.go | 24 --------- .../sqlstore/migrations/migrations.go | 3 -- 10 files changed, 113 deletions(-) delete mode 100644 pkg/services/export/export_live.go delete mode 100644 pkg/services/sqlstore/migrations/live_mig.go 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 ea82fe1bfc7..183a353f45a 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -60,7 +60,6 @@ Alpha features might be changed or removed without prior notice. | `returnUnameHeader` | Return user login as header for authenticated requests | | `alertingBigTransactions` | Use big transactions for alerting database writes | | `dashboardPreviews` | Create and show thumbnails for dashboard search results | -| `live-config` | Save Grafana Live configuration in SQL tables | | `live-pipeline` | Enable a generic live processing pipeline | | `live-service-web-worker` | This will use a webworker thread to processes events rather than the main thread | | `queryOverLive` | Use Grafana Live WebSocket to execute backend queries | diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index ea12eb94ce2..01d05ba7f42 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -23,7 +23,6 @@ export interface FeatureToggles { database_metrics?: boolean; dashboardPreviews?: boolean; dashboardPreviewsAdmin?: boolean; - ['live-config']?: boolean; ['live-pipeline']?: boolean; ['live-service-web-worker']?: boolean; queryOverLive?: boolean; diff --git a/pkg/services/export/export_live.go b/pkg/services/export/export_live.go deleted file mode 100644 index c8607353ab0..00000000000 --- a/pkg/services/export/export_live.go +++ /dev/null @@ -1,50 +0,0 @@ -package export - -import ( - "fmt" - "path" - "time" - - "github.com/grafana/grafana/pkg/infra/db" -) - -func exportLive(helper *commitHelper, job *gitExportJob) error { - messagedir := path.Join(helper.orgDir, "system", "live", "message") - - return job.sql.WithDbSession(helper.ctx, func(sess *db.Session) error { - type msgResult struct { - Channel string `xorm:"channel"` - Data string `xorm:"data"` - CreatedBy int64 `xorm:"created_by"` - Created time.Time `xorm:"created"` - } - - rows := make([]*msgResult, 0) - - sess.Table("live_message").Where("org_id = ?", helper.orgID) - - err := sess.Find(&rows) - if err != nil { - if isTableNotExistsError(err) { - return nil - } - return err - } - - for _, row := range rows { - err = helper.add(commitOptions{ - body: []commitBody{{ - body: []byte(row.Data), - fpath: path.Join(messagedir, row.Channel) + ".json", // must be JSON files - }}, - comment: fmt.Sprintf("Exporting: %s", row.Channel), - when: row.Created, - userID: row.CreatedBy, - }) - if err != nil { - return err - } - } - return err - }) -} diff --git a/pkg/services/export/service.go b/pkg/services/export/service.go index 173635c524b..011d68eb9cd 100644 --- a/pkg/services/export/service.go +++ b/pkg/services/export/service.go @@ -107,12 +107,6 @@ var exporters = []Exporter{ Description: "saved links", process: exportSystemShortURL, }, - { - Key: "system_live", - Name: "Grafana live", - Description: "archived messages", - process: exportLive, - }, }, }, { diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 04767c8549d..77ff410e164 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -45,11 +45,6 @@ var ( State: FeatureStateAlpha, RequiresDevMode: true, }, - { - Name: "live-config", - Description: "Save Grafana Live configuration in SQL tables", - State: FeatureStateAlpha, - }, { Name: "live-pipeline", Description: "Enable a generic live processing pipeline", diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index b47a1e88240..4087ca1bdf5 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -35,10 +35,6 @@ const ( // Manage the dashboard previews crawler process from the UI FlagDashboardPreviewsAdmin = "dashboardPreviewsAdmin" - // FlagLiveConfig - // Save Grafana Live configuration in SQL tables - FlagLiveConfig = "live-config" - // FlagLivePipeline // Enable a generic live processing pipeline FlagLivePipeline = "live-pipeline" diff --git a/pkg/services/featuremgmt/toggles_gen_test.go b/pkg/services/featuremgmt/toggles_gen_test.go index 147cdda2af0..11413f13b0e 100644 --- a/pkg/services/featuremgmt/toggles_gen_test.go +++ b/pkg/services/featuremgmt/toggles_gen_test.go @@ -22,7 +22,6 @@ func TestFeatureToggleFiles(t *testing.T) { "httpclientprovider_azure_auth": true, "service-accounts": true, "database_metrics": true, - "live-config": true, "live-pipeline": true, "live-service-web-worker": true, "k8s": true, // Camel case does not like this one diff --git a/pkg/services/live/database/storage.go b/pkg/services/live/database/storage.go index 9d829a5f9ad..3736c27d265 100644 --- a/pkg/services/live/database/storage.go +++ b/pkg/services/live/database/storage.go @@ -24,16 +24,6 @@ func getLiveMessageCacheKey(orgID int64, channel string) string { func (s *Storage) SaveLiveMessage(query *model.SaveLiveMessageQuery) error { // Come back to saving into database after evaluating database structure. - //err := s.store.WithDbSession(context.Background(), func(sess *db.Session) error { - // params := []interface{}{query.OrgId, query.Channel, query.Data, time.Now()} - // upsertSQL := s.store.Dialect.UpsertSQL( - // "live_message", - // []string{"org_id", "channel"}, - // []string{"org_id", "channel", "data", "published"}) - // _, err := sess.SQL(upsertSQL, params...).Query() - // return err - //}) - // return err s.cache.Set(getLiveMessageCacheKey(query.OrgID, query.Channel), model.LiveMessage{ ID: 0, // Not used actually. OrgID: query.OrgID, @@ -46,14 +36,6 @@ func (s *Storage) SaveLiveMessage(query *model.SaveLiveMessageQuery) error { func (s *Storage) GetLiveMessage(query *model.GetLiveMessageQuery) (model.LiveMessage, bool, error) { // Come back to saving into database after evaluating database structure. - //var msg models.LiveMessage - //var exists bool - //err := s.store.WithDbSession(context.Background(), func(sess *db.Session) error { - // var err error - // exists, err = sess.Where("org_id=? AND channel=?", query.OrgId, query.Channel).Get(&msg) - // return err - //}) - //return msg, exists, err m, ok := s.cache.Get(getLiveMessageCacheKey(query.OrgID, query.Channel)) if !ok { return model.LiveMessage{}, false, nil diff --git a/pkg/services/sqlstore/migrations/live_mig.go b/pkg/services/sqlstore/migrations/live_mig.go deleted file mode 100644 index e8bcffd941d..00000000000 --- a/pkg/services/sqlstore/migrations/live_mig.go +++ /dev/null @@ -1,24 +0,0 @@ -package migrations - -import "github.com/grafana/grafana/pkg/services/sqlstore/migrator" - -// For now disable migration. For now we are using local cache as storage to evaluate ideas. -// This will be turned on soon though. -func addLiveChannelMigrations(mg *migrator.Migrator) { - //liveMessage := migrator.Table{ - // Name: "live_message", - // Columns: []*migrator.Column{ - // {Name: "id", Type: migrator.DB_BigInt, Nullable: false, IsPrimaryKey: true, IsAutoIncrement: true}, - // {Name: "org_id", Type: migrator.DB_BigInt, Nullable: false}, - // {Name: "channel", Type: migrator.DB_NVarchar, Length: 189, Nullable: false}, - // {Name: "data", Type: migrator.DB_Text, Nullable: false}, - // {Name: "published", Type: migrator.DB_DateTime, Nullable: false}, - // }, - // Indices: []*migrator.Index{ - // {Cols: []string{"org_id", "channel"}, Type: migrator.UniqueIndex}, - // }, - //} - // - //mg.AddMigration("create live message table", migrator.NewAddTableMigration(liveMessage)) - //mg.AddMigration("add index live_message.org_id_channel_unique", migrator.NewAddIndexMigration(liveMessage, liveMessage.Indices[0])) -} diff --git a/pkg/services/sqlstore/migrations/migrations.go b/pkg/services/sqlstore/migrations/migrations.go index 6084dacba03..468c864138a 100644 --- a/pkg/services/sqlstore/migrations/migrations.go +++ b/pkg/services/sqlstore/migrations/migrations.go @@ -54,9 +54,6 @@ func (*OSSMigrations) AddMigration(mg *Migrator) { ualert.AddDashAlertMigration(mg) addLibraryElementsMigrations(mg) if mg.Cfg != nil && mg.Cfg.IsFeatureToggleEnabled != nil { - if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagLiveConfig) { - addLiveChannelMigrations(mg) - } if mg.Cfg.IsFeatureToggleEnabled(featuremgmt.FlagDashboardPreviews) { addDashboardThumbsMigrations(mg) }