mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-23 12:44:05 -08:00
Rule manager: remove blocking channel in mail (#7631)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
52cdcc2a3b
commit
b83cbacbdd
|
@ -660,18 +660,14 @@ func main() {
|
|||
}
|
||||
{
|
||||
// Rule manager.
|
||||
// TODO(krasi) refactor ruleManager.Run() to be blocking to avoid using an extra blocking channel.
|
||||
cancel := make(chan struct{})
|
||||
g.Add(
|
||||
func() error {
|
||||
<-reloadReady.C
|
||||
ruleManager.Run()
|
||||
<-cancel
|
||||
return nil
|
||||
},
|
||||
func(err error) {
|
||||
ruleManager.Stop()
|
||||
close(cancel)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -875,8 +875,13 @@ func NewManager(o *ManagerOptions) *Manager {
|
|||
return m
|
||||
}
|
||||
|
||||
// Run starts processing of the rule manager.
|
||||
// Run starts processing of the rule manager. It is blocking.
|
||||
func (m *Manager) Run() {
|
||||
m.start()
|
||||
<-m.done
|
||||
}
|
||||
|
||||
func (m *Manager) start() {
|
||||
close(m.block)
|
||||
}
|
||||
|
||||
|
|
|
@ -716,7 +716,7 @@ func TestUpdate(t *testing.T) {
|
|||
Context: context.Background(),
|
||||
Logger: log.NewNopLogger(),
|
||||
})
|
||||
ruleManager.Run()
|
||||
ruleManager.start()
|
||||
defer ruleManager.Stop()
|
||||
|
||||
err := ruleManager.Update(10*time.Second, files, nil)
|
||||
|
@ -906,8 +906,8 @@ func TestMetricsUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
storage := teststorage.New(t)
|
||||
registry := prometheus.NewRegistry()
|
||||
defer storage.Close()
|
||||
registry := prometheus.NewRegistry()
|
||||
opts := promql.EngineOpts{
|
||||
Logger: nil,
|
||||
Reg: nil,
|
||||
|
@ -923,7 +923,7 @@ func TestMetricsUpdate(t *testing.T) {
|
|||
Logger: log.NewNopLogger(),
|
||||
Registerer: registry,
|
||||
})
|
||||
ruleManager.Run()
|
||||
ruleManager.start()
|
||||
defer ruleManager.Stop()
|
||||
|
||||
countMetrics := func() int {
|
||||
|
@ -997,7 +997,7 @@ func TestGroupStalenessOnRemoval(t *testing.T) {
|
|||
Logger: log.NewNopLogger(),
|
||||
})
|
||||
var stopped bool
|
||||
ruleManager.Run()
|
||||
ruleManager.start()
|
||||
defer func() {
|
||||
if !stopped {
|
||||
ruleManager.Stop()
|
||||
|
@ -1074,7 +1074,7 @@ func TestMetricsStalenessOnManagerShutdown(t *testing.T) {
|
|||
Logger: log.NewNopLogger(),
|
||||
})
|
||||
var stopped bool
|
||||
ruleManager.Run()
|
||||
ruleManager.start()
|
||||
defer func() {
|
||||
if !stopped {
|
||||
ruleManager.Stop()
|
||||
|
|
Loading…
Reference in a new issue