mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-01 08:01:39 -08:00
Ignore order when comparing the source tenants of two rule groups
This commit is contained in:
parent
75d3c11278
commit
a97576fc00
|
@ -869,18 +869,25 @@ func (g *Group) Equals(ng *Group) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
for i, gr := range g.rules {
|
||||
if gr.String() != ng.rules[i].String() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// compare source tenants ignoring their order
|
||||
if len(g.sourceTenants) != len(ng.sourceTenants) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, tenant := range g.sourceTenants {
|
||||
if ng.sourceTenants[i] != tenant {
|
||||
return false
|
||||
}
|
||||
thisSourceTenants := make(map[string]struct{}, len(g.sourceTenants))
|
||||
|
||||
for _, tenant := range g.sourceTenants {
|
||||
thisSourceTenants[tenant] = struct{}{}
|
||||
}
|
||||
|
||||
for i, gr := range g.rules {
|
||||
if gr.String() != ng.rules[i].String() {
|
||||
for _, tenant := range ng.sourceTenants {
|
||||
if _, ok := thisSourceTenants[tenant]; !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue