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,22 +875,27 @@ func (g *Group) Equals(ng *Group) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{
|
||||||
// compare source tenants ignoring their order
|
// compare source tenants
|
||||||
if len(g.sourceTenants) != len(ng.sourceTenants) {
|
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{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tenant := range ng.sourceTenants {
|
|
||||||
if _, ok := thisSourceTenants[tenant]; !ok {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyAndSort := func(x []string) []string {
|
||||||
|
copied := make([]string, len(x))
|
||||||
|
copy(copied, x)
|
||||||
|
sort.Strings(copied)
|
||||||
|
return copied
|
||||||
|
}
|
||||||
|
|
||||||
|
ngSourceTenantsCopy := copyAndSort(ng.sourceTenants)
|
||||||
|
gSourceTenantsCopy := copyAndSort(g.sourceTenants)
|
||||||
|
|
||||||
|
for i := range ngSourceTenantsCopy {
|
||||||
|
if gSourceTenantsCopy[i] != ngSourceTenantsCopy[i] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in a new issue