mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-05 13:47:10 +02:00
Discovery.Manager: close sync ch after sender() is stopped (#14465)
* close sync ch after sender() is stopped * break if chan is closed Signed-off-by: liyandi <littlepangdi@163.com> Co-authored-by: liyandi <liyandi@xiaomi.com>
This commit is contained in:
parent
f1c6fab7e1
commit
8eb445b8a4
@ -365,8 +365,10 @@ func (m *Manager) updater(ctx context.Context, p *Provider, updates chan []*targ
|
||||
|
||||
func (m *Manager) sender() {
|
||||
ticker := time.NewTicker(m.updatert)
|
||||
defer ticker.Stop()
|
||||
|
||||
defer func() {
|
||||
ticker.Stop()
|
||||
close(m.syncCh)
|
||||
}()
|
||||
for {
|
||||
select {
|
||||
case <-m.ctx.Done():
|
||||
|
@ -254,7 +254,10 @@ func (n *Manager) targetUpdateLoop(tsets <-chan map[string][]*targetgroup.Group)
|
||||
select {
|
||||
case <-n.stopRequested:
|
||||
return
|
||||
case ts := <-tsets:
|
||||
case ts, ok := <-tsets:
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
n.reload(ts)
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,10 @@ func (m *Manager) Run(tsets <-chan map[string][]*targetgroup.Group) error {
|
||||
go m.reloader()
|
||||
for {
|
||||
select {
|
||||
case ts := <-tsets:
|
||||
case ts, ok := <-tsets:
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
m.updateTsets(ts)
|
||||
|
||||
select {
|
||||
|
Loading…
Reference in New Issue
Block a user