grafana/pkg/services/ngalert/api/upgrade.go
Matthew Jacobson aa03b8f8a7
Alerting: Guided legacy alerting upgrade dry-run (#80071)
This PR has two steps that together create a functional dry-run capability for the migration.

By enabling the feature flag alertingPreviewUpgrade when on legacy alerting it will:
    a. Allow all Grafana Alerting background services except for the scheduler to start (multiorg alertmanager, state manager, routes, …).
    b. Allow the UI to show Grafana Alerting pages alongside legacy ones (with appropriate in-app warnings that UA is not actually running).
    c. Show a new “Alerting Upgrade” page and register associated /api/v1/upgrade endpoints that will allow the user to upgrade their organization live without restart and present a summary of the upgrade in a table.
2024-01-05 18:19:12 -05:00

49 lines
1.7 KiB
Go

package api
import (
"github.com/grafana/grafana/pkg/api/response"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
)
type UpgradeApiHandler struct {
svc *UpgradeSrv
}
func NewUpgradeApi(svc *UpgradeSrv) *UpgradeApiHandler {
return &UpgradeApiHandler{
svc: svc,
}
}
func (f *UpgradeApiHandler) handleRoutePostUpgradeOrg(ctx *contextmodel.ReqContext) response.Response {
return f.svc.RoutePostUpgradeOrg(ctx)
}
func (f *UpgradeApiHandler) handleRouteGetOrgUpgrade(ctx *contextmodel.ReqContext) response.Response {
return f.svc.RouteGetOrgUpgrade(ctx)
}
func (f *UpgradeApiHandler) handleRouteDeleteOrgUpgrade(ctx *contextmodel.ReqContext) response.Response {
return f.svc.RouteDeleteOrgUpgrade(ctx)
}
func (f *UpgradeApiHandler) handleRoutePostUpgradeAlert(ctx *contextmodel.ReqContext, dashboardIdParam string, panelIdParam string) response.Response {
return f.svc.RoutePostUpgradeAlert(ctx, dashboardIdParam, panelIdParam)
}
func (f *UpgradeApiHandler) handleRoutePostUpgradeDashboard(ctx *contextmodel.ReqContext, dashboardIdParam string) response.Response {
return f.svc.RoutePostUpgradeDashboard(ctx, dashboardIdParam)
}
func (f *UpgradeApiHandler) handleRoutePostUpgradeAllDashboards(ctx *contextmodel.ReqContext) response.Response {
return f.svc.RoutePostUpgradeAllDashboards(ctx)
}
func (f *UpgradeApiHandler) handleRoutePostUpgradeChannel(ctx *contextmodel.ReqContext, channelIdParam string) response.Response {
return f.svc.RoutePostUpgradeChannel(ctx, channelIdParam)
}
func (f *UpgradeApiHandler) handleRoutePostUpgradeAllChannels(ctx *contextmodel.ReqContext) response.Response {
return f.svc.RoutePostUpgradeAllChannels(ctx)
}