mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
rules: Fix sorting of result from (*Manager).RuleGroups (#5260)
The previous code was defective in that it never sorted groups within a file due to doing a multi-key sort incorrectly. Signed-off-by: David Symonds <dsymonds@gmail.com>
This commit is contained in:
parent
e72c875e63
commit
46361a7c85
|
@ -861,8 +861,12 @@ func (m *Manager) RuleGroups() []*Group {
|
||||||
rgs = append(rgs, g)
|
rgs = append(rgs, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort rule groups by file, then by name.
|
||||||
sort.Slice(rgs, func(i, j int) bool {
|
sort.Slice(rgs, func(i, j int) bool {
|
||||||
return rgs[i].file < rgs[j].file && rgs[i].name < rgs[j].name
|
if rgs[i].file != rgs[j].file {
|
||||||
|
return rgs[i].file < rgs[j].file
|
||||||
|
}
|
||||||
|
return rgs[i].name < rgs[j].name
|
||||||
})
|
})
|
||||||
|
|
||||||
return rgs
|
return rgs
|
||||||
|
|
Loading…
Reference in a new issue