mirror of https://github.com/grafana/grafana.git
[release-12.1.0] Alerting: Fix active time intervals when time interval is renamed (#108547)
Alerting: Fix active time intervals when time interval is renamed (#108534)
(cherry picked from commit cc869e7668
)
Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
parent
ee5cc5a271
commit
2a87c627ad
|
@ -440,6 +440,12 @@ func replaceMuteTiming(route *definitions.Route, oldName, newName string) int {
|
|||
updated++
|
||||
}
|
||||
}
|
||||
for idx := range route.ActiveTimeIntervals {
|
||||
if route.ActiveTimeIntervals[idx] == oldName {
|
||||
route.ActiveTimeIntervals[idx] = newName
|
||||
updated++
|
||||
}
|
||||
}
|
||||
for _, route := range route.Routes {
|
||||
updated += replaceMuteTiming(route, oldName, newName)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
],
|
||||
"mute_time_intervals": [
|
||||
"test-interval", "persisted-interval"
|
||||
],
|
||||
"active_time_intervals": [
|
||||
"test-interval", "persisted-interval"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -725,7 +725,9 @@ func TestIntegrationTimeIntervalReferentialIntegrity(t *testing.T) {
|
|||
updatedRoute := legacyCli.GetRoute(t)
|
||||
for idx, route := range updatedRoute.Routes {
|
||||
expectedTimeIntervals := replace(currentRoute.Routes[idx].MuteTimeIntervals, interval.Spec.Name, actual.Spec.Name)
|
||||
assert.Equalf(t, expectedTimeIntervals, route.MuteTimeIntervals, "time interval in routes should have been renamed but it did not")
|
||||
assert.Equalf(t, expectedTimeIntervals, route.MuteTimeIntervals, "mute time interval in routes should have been renamed but it did not")
|
||||
expectedTimeIntervals = replace(currentRoute.Routes[idx].ActiveTimeIntervals, interval.Spec.Name, actual.Spec.Name)
|
||||
assert.Equalf(t, expectedTimeIntervals, route.ActiveTimeIntervals, "active time interval in routes should have been renamed but it did not")
|
||||
}
|
||||
|
||||
interval = *actual
|
||||
|
|
Loading…
Reference in New Issue