mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Reduce set of fields that could trigger alert state change (#83496)
We want to avoid too much change of alert state based on change on alert's fields. For that we ignore some fields from the diff.
This commit is contained in:
parent
2188516a21
commit
6f38ac6615
@ -300,9 +300,7 @@ func (r ruleWithFolder) Fingerprint() fingerprint {
|
||||
// TODO consider removing fields below from the fingerprint
|
||||
writeInt(rule.ID)
|
||||
writeInt(rule.OrgID)
|
||||
writeInt(rule.IntervalSeconds)
|
||||
writeInt(int64(rule.For))
|
||||
writeLabels(rule.Annotations)
|
||||
if rule.DashboardUID != nil {
|
||||
writeString(*rule.DashboardUID)
|
||||
}
|
||||
|
@ -150,10 +150,13 @@ func TestRuleWithFolderFingerprint(t *testing.T) {
|
||||
f2 := ruleWithFolder{rule: rule, folderTitle: uuid.NewString()}.Fingerprint()
|
||||
require.NotEqual(t, f, f2)
|
||||
})
|
||||
t.Run("Version and Updated should be excluded from fingerprint", func(t *testing.T) {
|
||||
t.Run("Version, Updated, IntervalSeconds and Annotations should be excluded from fingerprint", func(t *testing.T) {
|
||||
cp := models.CopyRule(rule)
|
||||
cp.Version++
|
||||
cp.Updated = cp.Updated.Add(1 * time.Second)
|
||||
cp.IntervalSeconds++
|
||||
cp.Annotations = make(map[string]string)
|
||||
cp.Annotations["test"] = "test"
|
||||
|
||||
f2 := ruleWithFolder{rule: cp, folderTitle: title}.Fingerprint()
|
||||
require.Equal(t, f, f2)
|
||||
@ -242,6 +245,8 @@ func TestRuleWithFolderFingerprint(t *testing.T) {
|
||||
excludedFields := map[string]struct{}{
|
||||
"Version": {},
|
||||
"Updated": {},
|
||||
"IntervalSeconds": {},
|
||||
"Annotations": {},
|
||||
}
|
||||
|
||||
tp := reflect.TypeOf(rule).Elem()
|
||||
|
Loading…
Reference in New Issue
Block a user