Alerting: Fix notification policy conflicts originating from provenance mismatch (#107343)

* Alerting: Fix notification policy conflicts originating from provenance mismatch

Sometimes the provenance field on the notification policy route can mismatch with the actual provenance in the provenance store.

This leads to 409s when trying to update the notification policy via the k8s apis.

We avoid this by ignoring the provenance field when calculating the fingerprint.

Co-authored-by: Matt Jacobson <matthew.jacobson@grafana.com>

* fix tests which validate stability

---------

Co-authored-by: Matt Jacobson <matthew.jacobson@grafana.com>
This commit is contained in:
Moustafa Baiou
2025-07-02 17:26:27 +00:00
committed by GitHub
co-authored by Matt Jacobson
parent d9a8253640
commit 11ea1dfba8
2 changed files with 3 additions and 3 deletions
@@ -277,7 +277,6 @@ func writeToHash(sum hash.Hash, r *definitions.Route) {
writeDuration(r.GroupWait)
writeDuration(r.GroupInterval)
writeDuration(r.RepeatInterval)
writeString(string(r.Provenance))
for _, route := range r.Routes {
writeToHash(sum, route)
}
@@ -428,13 +428,14 @@ func TestRoute_Fingerprint(t *testing.T) {
}
t.Run("stable across code changes", func(t *testing.T) {
expectedFingerprint := "7faba12778df93b8" // If this is a valid fingerprint generation change, update the expected value.
expectedFingerprint := "450c06a7f4a66675" // If this is a valid fingerprint generation change, update the expected value.
assert.Equal(t, expectedFingerprint, calculateRouteFingerprint(baseRouteGen()))
})
t.Run("unstable across field modification", func(t *testing.T) {
fingerprint := calculateRouteFingerprint(baseRouteGen())
excludedFields := map[string]struct{}{
"Routes": {},
"Routes": {},
"Provenance": {},
}
reflectVal := reflect.ValueOf(&completelyDifferentRoute).Elem()