mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Live: remove feature toggle and enable by default (#33654)
This commit is contained in:
@@ -413,21 +413,19 @@ func (hs *HTTPServer) registerRoutes() {
|
||||
|
||||
apiRoute.Post("/frontend-metrics", bind(metrics.PostFrontendMetricsCommand{}), routing.Wrap(hs.PostFrontendMetrics))
|
||||
|
||||
if hs.Live.IsEnabled() {
|
||||
apiRoute.Group("/live", func(liveRoute routing.RouteRegister) {
|
||||
// the channel path is in the name
|
||||
liveRoute.Post("/publish", bind(dtos.LivePublishCmd{}), routing.Wrap(hs.Live.HandleHTTPPublish))
|
||||
apiRoute.Group("/live", func(liveRoute routing.RouteRegister) {
|
||||
// the channel path is in the name
|
||||
liveRoute.Post("/publish", bind(dtos.LivePublishCmd{}), routing.Wrap(hs.Live.HandleHTTPPublish))
|
||||
|
||||
// POST influx line protocol
|
||||
liveRoute.Post("/push/:streamId", hs.LivePushGateway.Handle)
|
||||
// POST influx line protocol
|
||||
liveRoute.Post("/push/:streamId", hs.LivePushGateway.Handle)
|
||||
|
||||
// List available streams and fields
|
||||
liveRoute.Get("/list", routing.Wrap(hs.Live.HandleListHTTP))
|
||||
// List available streams and fields
|
||||
liveRoute.Get("/list", routing.Wrap(hs.Live.HandleListHTTP))
|
||||
|
||||
// Some channels may have info
|
||||
liveRoute.Get("/info/*", routing.Wrap(hs.Live.HandleInfoHTTP))
|
||||
})
|
||||
}
|
||||
// Some channels may have info
|
||||
liveRoute.Get("/info/*", routing.Wrap(hs.Live.HandleInfoHTTP))
|
||||
})
|
||||
|
||||
// short urls
|
||||
apiRoute.Post("/short-urls", bind(dtos.CreateShortURLCmd{}), routing.Wrap(hs.createShortURL))
|
||||
|
||||
@@ -270,8 +270,8 @@ func (hs *HTTPServer) deleteDashboard(c *models.ReqContext) response.Response {
|
||||
return response.Error(500, "Failed to delete dashboard", err)
|
||||
}
|
||||
|
||||
if hs.Live.IsEnabled() {
|
||||
err := hs.Live.GrafanaScope.Dashboards.DashboardDeleted(c.ToUserDisplayDTO(), dash.Uid)
|
||||
if hs.Live != nil {
|
||||
err = hs.Live.GrafanaScope.Dashboards.DashboardDeleted(c.ToUserDisplayDTO(), dash.Uid)
|
||||
if err != nil {
|
||||
hs.log.Error("Failed to broadcast delete info", "dashboard", dash.Uid, "error", err)
|
||||
}
|
||||
@@ -337,8 +337,8 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
|
||||
dashSvc := dashboards.NewService(hs.SQLStore)
|
||||
dashboard, err := dashSvc.SaveDashboard(dashItem, allowUiUpdate)
|
||||
|
||||
// Tell everyone listening that the dashboard changed
|
||||
if hs.Live.IsEnabled() {
|
||||
if hs.Live != nil {
|
||||
// Tell everyone listening that the dashboard changed
|
||||
if dashboard == nil {
|
||||
dashboard = dash // the original request
|
||||
}
|
||||
@@ -360,6 +360,7 @@ func (hs *HTTPServer) PostDashboard(c *models.ReqContext, cmd models.SaveDashboa
|
||||
hs.log.Warn("unable to broadcast save event", "uid", dashboard.Uid, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return hs.dashboardSaveErrorToApiResponse(err)
|
||||
}
|
||||
|
||||
@@ -78,6 +78,14 @@ type testState struct {
|
||||
dashQueries []*models.GetDashboardQuery
|
||||
}
|
||||
|
||||
func newTestLive(t *testing.T) *live.GrafanaLive {
|
||||
gLive := live.NewGrafanaLive()
|
||||
gLive.RouteRegister = routing.NewRouteRegister()
|
||||
err := gLive.Init()
|
||||
require.NoError(t, err)
|
||||
return gLive
|
||||
}
|
||||
|
||||
// This tests three main scenarios.
|
||||
// If a user has access to execute an action on a dashboard:
|
||||
// 1. and the dashboard is in a folder which does not have an acl
|
||||
@@ -263,7 +271,8 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
|
||||
t.Run("Given a dashboard with a parent folder which has an ACL", func(t *testing.T) {
|
||||
hs := &HTTPServer{
|
||||
Cfg: setting.NewCfg(),
|
||||
Cfg: setting.NewCfg(),
|
||||
Live: newTestLive(t),
|
||||
}
|
||||
|
||||
setUp := func() *testState {
|
||||
@@ -1172,7 +1181,7 @@ func postDashboardScenario(t *testing.T, desc string, url string, routePattern s
|
||||
Bus: bus.GetBus(),
|
||||
Cfg: cfg,
|
||||
ProvisioningService: provisioning.NewProvisioningServiceMock(),
|
||||
Live: &live.GrafanaLive{Cfg: setting.NewCfg()},
|
||||
Live: newTestLive(t),
|
||||
QuotaService: "a.QuotaService{
|
||||
Cfg: cfg,
|
||||
},
|
||||
@@ -1236,7 +1245,7 @@ func restoreDashboardVersionScenario(t *testing.T, desc string, url string, rout
|
||||
Cfg: cfg,
|
||||
Bus: bus.GetBus(),
|
||||
ProvisioningService: provisioning.NewProvisioningServiceMock(),
|
||||
Live: &live.GrafanaLive{Cfg: cfg},
|
||||
Live: newTestLive(t),
|
||||
QuotaService: "a.QuotaService{Cfg: cfg},
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ func (g *GrafanaLive) getStreamPlugin(pluginID string) (backend.StreamHandler, e
|
||||
// AddMigration defines database migrations.
|
||||
// This is an implementation of registry.DatabaseMigrator.
|
||||
func (g *GrafanaLive) AddMigration(mg *migrator.Migrator) {
|
||||
if !g.IsEnabled() {
|
||||
if g == nil || g.Cfg == nil || !g.Cfg.IsLiveConfigEnabled() {
|
||||
return
|
||||
}
|
||||
database.AddLiveChannelMigrations(mg)
|
||||
@@ -136,11 +136,6 @@ var clientConcurrency = 8
|
||||
func (g *GrafanaLive) Init() error {
|
||||
logger.Debug("GrafanaLive initialization")
|
||||
|
||||
if !g.IsEnabled() {
|
||||
logger.Debug("GrafanaLive feature not enabled, skipping initialization")
|
||||
return nil
|
||||
}
|
||||
|
||||
// We use default config here as starting point. Default config contains
|
||||
// reasonable values for available options.
|
||||
cfg := centrifuge.DefaultConfig
|
||||
@@ -530,14 +525,6 @@ func (g *GrafanaLive) ClientCount(channel string) (int, error) {
|
||||
return len(p.Presence), nil
|
||||
}
|
||||
|
||||
// IsEnabled returns true if the Grafana Live feature is enabled.
|
||||
func (g *GrafanaLive) IsEnabled() bool {
|
||||
if g == nil || g.Cfg == nil {
|
||||
return false
|
||||
}
|
||||
return g.Cfg.IsLiveEnabled()
|
||||
}
|
||||
|
||||
func (g *GrafanaLive) HandleHTTPPublish(ctx *models.ReqContext, cmd dtos.LivePublishCmd) response.Response {
|
||||
addr := live.ParseChannel(cmd.Channel)
|
||||
if !addr.IsValid() {
|
||||
|
||||
@@ -34,30 +34,16 @@ type Gateway struct {
|
||||
func (g *Gateway) Init() error {
|
||||
logger.Info("Telemetry Gateway initialization")
|
||||
|
||||
if !g.IsEnabled() {
|
||||
logger.Debug("Telemetry Gateway not enabled, skipping initialization")
|
||||
return nil
|
||||
}
|
||||
|
||||
g.converter = convert.NewConverter()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run Gateway.
|
||||
func (g *Gateway) Run(ctx context.Context) error {
|
||||
if !g.IsEnabled() {
|
||||
logger.Debug("GrafanaLive feature not enabled, skipping initialization of Telemetry Gateway")
|
||||
return nil
|
||||
}
|
||||
<-ctx.Done()
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
// IsEnabled returns true if the Grafana Live feature is enabled.
|
||||
func (g *Gateway) IsEnabled() bool {
|
||||
return g.Cfg.IsLiveEnabled() // turn on when Live on for now.
|
||||
}
|
||||
|
||||
func (g *Gateway) Handle(ctx *models.ReqContext) {
|
||||
streamID := ctx.Params(":streamId")
|
||||
|
||||
|
||||
@@ -374,9 +374,9 @@ type Cfg struct {
|
||||
ImageUploadProvider string
|
||||
}
|
||||
|
||||
// IsLiveEnabled returns if grafana live should be enabled
|
||||
func (cfg Cfg) IsLiveEnabled() bool {
|
||||
return cfg.FeatureToggles["live"]
|
||||
// IsLiveConfigEnabled returns true if live should be able to save configs to SQL tables
|
||||
func (cfg Cfg) IsLiveConfigEnabled() bool {
|
||||
return cfg.FeatureToggles["live-config"]
|
||||
}
|
||||
|
||||
// IsNgAlertEnabled returns whether the standalone alerts feature is enabled.
|
||||
|
||||
Reference in New Issue
Block a user