mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix force_migration when alerting is disabled (#50431)
* Alerting: Fix force_migration when alerting is disabled This commit fixes a bug where force_migration must be set to true when both unified and legacy alerting is disabled. * Update comment * Fix typo in comment Co-authored-by: Armand Grillet <armand.grillet@outlook.com>
This commit is contained in:
parent
3fa7f72d6c
commit
0bd12ab531
@ -59,6 +59,7 @@ func AddDashAlertMigration(mg *migrator.Migrator) {
|
|||||||
_, migrationRun := logs[migTitle]
|
_, migrationRun := logs[migTitle]
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
// If unified alerting is enabled and the upgrade migration has not been run
|
||||||
case mg.Cfg.UnifiedAlerting.IsEnabled() && !migrationRun:
|
case mg.Cfg.UnifiedAlerting.IsEnabled() && !migrationRun:
|
||||||
// Remove the migration entry that removes all unified alerting data. This is so when the feature
|
// 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.
|
// flag is removed in future the "remove unified alerting data" migration will be run again.
|
||||||
@ -72,7 +73,13 @@ func AddDashAlertMigration(mg *migrator.Migrator) {
|
|||||||
seenChannelUIDs: make(map[string]struct{}),
|
seenChannelUIDs: make(map[string]struct{}),
|
||||||
silences: make(map[int64][]*pb.MeshSilence),
|
silences: make(map[int64][]*pb.MeshSilence),
|
||||||
})
|
})
|
||||||
|
// If unified alerting is disabled and upgrade migration has been run
|
||||||
case !mg.Cfg.UnifiedAlerting.IsEnabled() && migrationRun:
|
case !mg.Cfg.UnifiedAlerting.IsEnabled() && migrationRun:
|
||||||
|
// If legacy alerting is also disabled, there is nothing to do
|
||||||
|
if setting.AlertingEnabled != nil && !*setting.AlertingEnabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Safeguard to prevent data loss when migrating from UA to LA
|
// Safeguard to prevent data loss when migrating from UA to LA
|
||||||
if !mg.Cfg.ForceMigration {
|
if !mg.Cfg.ForceMigration {
|
||||||
panic("Grafana has already been migrated to Unified Alerting.\nAny alert rules created while using Unified Alerting will be deleted by rolling back.\n\nSet force_migration=true in your grafana.ini and restart Grafana to roll back and delete Unified Alerting configuration data.")
|
panic("Grafana has already been migrated to Unified Alerting.\nAny alert rules created while using Unified Alerting will be deleted by rolling back.\n\nSet force_migration=true in your grafana.ini and restart Grafana to roll back and delete Unified Alerting configuration data.")
|
||||||
|
Loading…
Reference in New Issue
Block a user