Live: remove feature toggle and enable by default (#33654)

This commit is contained in:
Ryan McKinley
2021-05-04 08:44:55 -07:00
committed by GitHub
parent 9315152d4f
commit 33e4f8d7ac
11 changed files with 35 additions and 63 deletions
+10 -12
View File
@@ -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))
+5 -4
View File
@@ -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)
}
+12 -3
View File
@@ -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: &quota.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: &quota.QuotaService{Cfg: cfg},
}