mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
Merge pull request #1024 from prometheus/fix-updatetargets-busyloop
Fix busylooping in case of no target providers.
This commit is contained in:
commit
25a8bd50a5
|
@ -171,12 +171,15 @@ func (tm *TargetManager) Run() {
|
|||
tm.running = true
|
||||
}
|
||||
|
||||
// handleTargetUpdates receives target group updates and handles them in the
|
||||
// handleUpdates receives target group updates and handles them in the
|
||||
// context of the given job config.
|
||||
func (tm *TargetManager) handleUpdates(ch <-chan targetGroupUpdate, done <-chan struct{}) {
|
||||
for {
|
||||
select {
|
||||
case update := <-ch:
|
||||
case update, ok := <-ch:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if update.tg == nil {
|
||||
break
|
||||
}
|
||||
|
|
|
@ -376,3 +376,10 @@ func TestTargetManagerConfigUpdate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandleUpdatesReturnsWhenUpdateChanIsClosed(t *testing.T) {
|
||||
tm := NewTargetManager(nopAppender{})
|
||||
ch := make(chan targetGroupUpdate)
|
||||
close(ch)
|
||||
tm.handleUpdates(ch, make(chan struct{}))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue