Merge pull request #10569 from zzJinux/discovery-manager-run

Fix discovery managers to be properly cancelled
This commit is contained in:
Julien Pivotto 2023-09-29 12:07:55 +02:00 committed by GitHub
commit 4b735f02a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -140,11 +140,9 @@ type Manager struct {
// Run starts the background processing // Run starts the background processing
func (m *Manager) Run() error { func (m *Manager) Run() error {
go m.sender() go m.sender()
for range m.ctx.Done() { <-m.ctx.Done()
m.cancelDiscoverers() m.cancelDiscoverers()
return m.ctx.Err() return m.ctx.Err()
}
return nil
} }
// SyncCh returns a read only channel used by all the clients to receive target updates. // SyncCh returns a read only channel used by all the clients to receive target updates.

View File

@ -180,11 +180,9 @@ func (m *Manager) Providers() []*Provider {
// Run starts the background processing. // Run starts the background processing.
func (m *Manager) Run() error { func (m *Manager) Run() error {
go m.sender() go m.sender()
for range m.ctx.Done() { <-m.ctx.Done()
m.cancelDiscoverers() m.cancelDiscoverers()
return m.ctx.Err() return m.ctx.Err()
}
return nil
} }
// SyncCh returns a read only channel used by all the clients to receive target updates. // SyncCh returns a read only channel used by all the clients to receive target updates.