Skip to content

Commit

Permalink
Merge "Prevent spurious prometheus rules update"
Browse files Browse the repository at this point in the history
  • Loading branch information
Microzuul CI authored and Gerrit Code Review committed Nov 14, 2023
2 parents 9511e5b + 94f2960 commit 963d169
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions controllers/libs/monitoring/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package monitoring

import (
"math"
"sort"
"strconv"
"strings"

Expand Down Expand Up @@ -178,11 +179,23 @@ func MkAlertRuleChecksumString(alertRule monitoringv1.Rule) string {
_for := *alertRule.For
checksumable += string(_for)
}
for k, v := range alertRule.Labels {
checksumable += k + "." + v

var labels []string
for label := range alertRule.Labels {
labels = append(labels, label)
}
sort.Strings(labels)
for _, label := range labels {
checksumable += label + "." + alertRule.Labels[label]
}

var annotations []string
for annotation := range alertRule.Annotations {
annotations = append(annotations, annotation)
}
for k, v := range alertRule.Annotations {
checksumable += k + ":" + v
sort.Strings(annotations)
for _, annotation := range annotations {
checksumable += annotation + ":" + alertRule.Annotations[annotation]
}
return checksumable
}
Expand Down

0 comments on commit 963d169

Please sign in to comment.