Alerting: Fix creating a new alert rule vesion when only keep_firing_for changes (#114926)

Alerting: Create alert rule vesion when keep_firing_for changes
This commit is contained in:
Alexander Akhmetov
2025-12-05 18:02:11 +01:00
committed by GitHub
parent 0adb2461e9
commit 74c7b5a292
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -88,6 +88,7 @@ func (a alertRuleVersion) EqualSpec(b alertRuleVersion) bool {
a.NoDataState == b.NoDataState && a.NoDataState == b.NoDataState &&
a.ExecErrState == b.ExecErrState && a.ExecErrState == b.ExecErrState &&
a.For == b.For && a.For == b.For &&
a.KeepFiringFor == b.KeepFiringFor &&
a.Annotations == b.Annotations && a.Annotations == b.Annotations &&
a.Labels == b.Labels && a.Labels == b.Labels &&
a.IsPaused == b.IsPaused && a.IsPaused == b.IsPaused &&
@@ -21,6 +21,7 @@ func TestAlertRuleVersion_EqualSpec(t *testing.T) {
NoDataState: "state1", NoDataState: "state1",
ExecErrState: "state2", ExecErrState: "state2",
For: time.Minute, For: time.Minute,
KeepFiringFor: 2 * time.Minute,
Annotations: `{ "test": "annotation" }`, Annotations: `{ "test": "annotation" }`,
Labels: `{ "test": "label" }`, Labels: `{ "test": "label" }`,
IsPaused: true, IsPaused: true,
@@ -119,6 +120,12 @@ func TestAlertRuleVersion_EqualSpec(t *testing.T) {
b: func() alertRuleVersion { v := baseVersion; v.For = 2 * time.Minute; return v }(), b: func() alertRuleVersion { v := baseVersion; v.For = 2 * time.Minute; return v }(),
expect: false, expect: false,
}, },
{
name: "different KeepFiringFor durations",
a: baseVersion,
b: func() alertRuleVersion { v := baseVersion; v.KeepFiringFor = 5 * time.Minute; return v }(),
expect: false,
},
{ {
name: "exact match including bools and other types", name: "exact match including bools and other types",
a: func() alertRuleVersion { a: func() alertRuleVersion {