mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 06:07:11 +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() {
|
func (m *Manager) sender() {
|
||||||
ticker := time.NewTicker(m.updatert)
|
ticker := time.NewTicker(m.updatert)
|
||||||
defer ticker.Stop()
|
defer func() {
|
||||||
|
ticker.Stop()
|
||||||
|
close(m.syncCh)
|
||||||
|
}()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-m.ctx.Done():
|
case <-m.ctx.Done():
|
||||||
|
@ -254,7 +254,10 @@ func (n *Manager) targetUpdateLoop(tsets <-chan map[string][]*targetgroup.Group)
|
|||||||
select {
|
select {
|
||||||
case <-n.stopRequested:
|
case <-n.stopRequested:
|
||||||
return
|
return
|
||||||
case ts := <-tsets:
|
case ts, ok := <-tsets:
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
n.reload(ts)
|
n.reload(ts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,10 @@ func (m *Manager) Run(tsets <-chan map[string][]*targetgroup.Group) error {
|
|||||||
go m.reloader()
|
go m.reloader()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case ts := <-tsets:
|
case ts, ok := <-tsets:
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
m.updateTsets(ts)
|
m.updateTsets(ts)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user