Alerting: Add clean_upgrade config and deprecate force_migration (#78324)
* Alerting: Add clean_upgrade config and deprecate force_migration Upgrading to UA and rolling back will no longer delete any data by default. Instead, each set of tables will remain unchanged when switching between legacy and UA. As such, the force_migration config has been deprecated and no extra configuration is required to roll back to legacy anymore. If clean_upgrade is set to true when upgrading from legacy alerting to Unified Alerting, grafana will first delete all existing Unified Alerting resources, thus re-upgrading all organizations from scratch. If false or unset, organizations that have previously upgraded will not lose their existing Unified Alerting data when switching between legacy and Unified Alerting. Similar to force_migration, it should be kept false when not needed as it may cause unintended data-loss if left enabled. --------- Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
This commit is contained in:
co-authored by
Christopher Moyer
parent
0f0249abea
commit
5a80962de9
@@ -416,6 +416,7 @@ type Cfg struct {
|
||||
StackID string
|
||||
Slug string
|
||||
|
||||
// Deprecated
|
||||
ForceMigration bool
|
||||
|
||||
// Analytics
|
||||
@@ -1061,6 +1062,7 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
|
||||
cfg.Env = Env
|
||||
cfg.StackID = valueAsString(iniFile.Section("environment"), "stack_id", "")
|
||||
cfg.Slug = valueAsString(iniFile.Section("environment"), "stack_slug", "")
|
||||
//nolint:staticcheck
|
||||
cfg.ForceMigration = iniFile.Section("").Key("force_migration").MustBool(false)
|
||||
InstanceName = valueAsString(iniFile.Section(""), "instance_name", "unknown_instance_name")
|
||||
plugins := valueAsString(iniFile.Section("paths"), "plugins", "")
|
||||
|
||||
@@ -96,6 +96,7 @@ type UnifiedAlertingSettings struct {
|
||||
ReservedLabels UnifiedAlertingReservedLabelSettings
|
||||
StateHistory UnifiedAlertingStateHistorySettings
|
||||
RemoteAlertmanager RemoteAlertmanagerSettings
|
||||
Upgrade UnifiedAlertingUpgradeSettings
|
||||
// MaxStateSaveConcurrency controls the number of goroutines (per rule) that can save alert state in parallel.
|
||||
MaxStateSaveConcurrency int
|
||||
}
|
||||
@@ -136,6 +137,11 @@ type UnifiedAlertingStateHistorySettings struct {
|
||||
ExternalLabels map[string]string
|
||||
}
|
||||
|
||||
type UnifiedAlertingUpgradeSettings struct {
|
||||
// CleanUpgrade controls whether the upgrade process should clean up UA data when upgrading from legacy alerting.
|
||||
CleanUpgrade bool
|
||||
}
|
||||
|
||||
// IsEnabled returns true if UnifiedAlertingSettings.Enabled is either nil or true.
|
||||
// It hides the implementation details of the Enabled and simplifies its usage.
|
||||
func (u *UnifiedAlertingSettings) IsEnabled() bool {
|
||||
@@ -399,6 +405,12 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
|
||||
|
||||
uaCfg.MaxStateSaveConcurrency = ua.Key("max_state_save_concurrency").MustInt(1)
|
||||
|
||||
upgrade := iniFile.Section("unified_alerting.upgrade")
|
||||
uaCfgUpgrade := UnifiedAlertingUpgradeSettings{
|
||||
CleanUpgrade: upgrade.Key("clean_upgrade").MustBool(false),
|
||||
}
|
||||
uaCfg.Upgrade = uaCfgUpgrade
|
||||
|
||||
cfg.UnifiedAlerting = uaCfg
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user