mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Remove UALERT_MIG env guard from dashboard rule migration (#34384)
Rules/notifications/etc migration will now be activated with feature flag alone. When the feature flag is enabled dashboard alerts are migrated into the system. When the feature flag is removed, all migrated and newly created alerts in the new system are deleted.
This commit is contained in:
parent
9dfaa037d1
commit
b987237c9b
@ -31,9 +31,6 @@ func (e MigrationError) Error() string {
|
|||||||
func (e *MigrationError) Unwrap() error { return e.Err }
|
func (e *MigrationError) Unwrap() error { return e.Err }
|
||||||
|
|
||||||
func AddDashAlertMigration(mg *migrator.Migrator) {
|
func AddDashAlertMigration(mg *migrator.Migrator) {
|
||||||
if os.Getenv("UALERT_MIG") == "iDidBackup" {
|
|
||||||
// TODO: unified alerting DB needs to be extacted into ../migrations.go
|
|
||||||
// so it runs and creates the tables before this migration runs.
|
|
||||||
logs, err := mg.GetMigrationLog()
|
logs, err := mg.GetMigrationLog()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mg.Logger.Crit("alert migration failure: could not get migration log", "error", err)
|
mg.Logger.Crit("alert migration failure: could not get migration log", "error", err)
|
||||||
@ -46,21 +43,23 @@ func AddDashAlertMigration(mg *migrator.Migrator) {
|
|||||||
|
|
||||||
switch {
|
switch {
|
||||||
case ngEnabled && !migrationRun:
|
case ngEnabled && !migrationRun:
|
||||||
// clear the entry of the migration that
|
// Remove the migration entry that removes all unified alerting data. This is so when the feature
|
||||||
|
// flag is removed in future the "remove unified alerting data" migration will be run again.
|
||||||
err = mg.ClearMigrationEntry(rmMigTitle)
|
err = mg.ClearMigrationEntry(rmMigTitle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mg.Logger.Error("alert migration error: could not clear alert migration for removing data", "error", err)
|
mg.Logger.Error("alert migration error: could not clear alert migration for removing data", "error", err)
|
||||||
}
|
}
|
||||||
mg.AddMigration(migTitle, &migration{})
|
mg.AddMigration(migTitle, &migration{})
|
||||||
case !ngEnabled && migrationRun:
|
case !ngEnabled && migrationRun:
|
||||||
|
// Remove the migration entry that creates unified alerting data. This is so when the feature
|
||||||
|
// flag is enabled in the future the migration "move dashboard alerts to unified alerting" will be run again.
|
||||||
err = mg.ClearMigrationEntry(migTitle)
|
err = mg.ClearMigrationEntry(migTitle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mg.Logger.Error("alert migration error: could not clear alert migration", "error", err)
|
mg.Logger.Error("alert migration error: could not clear dashboard alert migration", "error", err)
|
||||||
}
|
}
|
||||||
mg.AddMigration(rmMigTitle, &rmMigration{})
|
mg.AddMigration(rmMigTitle, &rmMigration{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
type migration struct {
|
type migration struct {
|
||||||
migrator.MigrationBase
|
migrator.MigrationBase
|
||||||
|
Loading…
Reference in New Issue
Block a user