mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Live: Remove dev code that would save config and messages in SQL (#62912)
This commit is contained in:
parent
84a6671911
commit
72790b0614
@ -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 |
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
})
|
||||
}
|
@ -107,12 +107,6 @@ var exporters = []Exporter{
|
||||
Description: "saved links",
|
||||
process: exportSystemShortURL,
|
||||
},
|
||||
{
|
||||
Key: "system_live",
|
||||
Name: "Grafana live",
|
||||
Description: "archived messages",
|
||||
process: exportLive,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -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",
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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]))
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user