Alerting: Fix state cache id duplication (#33480)

This commit is contained in:
Kyle Brandt
2021-04-28 11:42:19 -04:00
committed by GitHub
parent 7509c6cbc4
commit 914443c816
6 changed files with 53 additions and 32 deletions
@@ -38,6 +38,15 @@ func (il *InstanceLabels) ToDB() ([]byte, error) {
return []byte{}, fmt.Errorf("database serialization of alerting ng Instance labels is not implemented")
}
func (il *InstanceLabels) StringKey() (string, error) {
tl := labelsToTupleLabels(*il)
b, err := json.Marshal(tl)
if err != nil {
return "", fmt.Errorf("can not gereate key due to failure to encode labels: %w", err)
}
return string(b), nil
}
// StringAndHash returns a the json representation of the labels as tuples
// sorted by key. It also returns the a hash of that representation.
func (il *InstanceLabels) StringAndHash() (string, string, error) {