mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-15 01:54:06 -08:00
Account for repeating tenants when comparing rules
This commit is contained in:
parent
bc7a802871
commit
16faee8b78
|
@ -875,23 +875,28 @@ func (g *Group) Equals(ng *Group) bool {
|
|||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// compare source tenants ignoring their order
|
||||
{
|
||||
// compare source tenants
|
||||
if len(g.sourceTenants) != len(ng.sourceTenants) {
|
||||
return false
|
||||
}
|
||||
|
||||
thisSourceTenants := make(map[string]struct{}, len(g.sourceTenants))
|
||||
|
||||
for _, tenant := range g.sourceTenants {
|
||||
thisSourceTenants[tenant] = struct{}{}
|
||||
copyAndSort := func(x []string) []string {
|
||||
copied := make([]string, len(x))
|
||||
copy(copied, x)
|
||||
sort.Strings(copied)
|
||||
return copied
|
||||
}
|
||||
|
||||
for _, tenant := range ng.sourceTenants {
|
||||
if _, ok := thisSourceTenants[tenant]; !ok {
|
||||
ngSourceTenantsCopy := copyAndSort(ng.sourceTenants)
|
||||
gSourceTenantsCopy := copyAndSort(g.sourceTenants)
|
||||
|
||||
for i := range ngSourceTenantsCopy {
|
||||
if gSourceTenantsCopy[i] != ngSourceTenantsCopy[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue