From a535c8d1b4089a58b5513f3aa50afd17be37833c Mon Sep 17 00:00:00 2001 From: Krasi Georgiev Date: Sun, 14 Jan 2018 19:42:31 +0000 Subject: [PATCH] simplify the pool cleanup --- retrieval/manager.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/retrieval/manager.go b/retrieval/manager.go index c27bd95078..5cf05b79bf 100644 --- a/retrieval/manager.go +++ b/retrieval/manager.go @@ -146,20 +146,15 @@ func (m *ScrapeManager) reload(t map[string][]*targetgroup.Group) error { } else { existing.Sync(tgroup) } + } - // Cleanup - check the config and cancel the scrape loops if it don't exist in the scrape config. - jobs := make(map[string]struct{}) - - for k := range m.scrapeConfigs { - jobs[k] = struct{}{} - } - - for name, sp := range m.scrapePools { - if _, ok := jobs[name]; !ok { - sp.stop() - delete(m.scrapePools, name) - } + // Cleanup - check the config and cancel the scrape loops if it don't exist in the scrape config. + for name, sp := range m.scrapePools { + if _, ok := m.scrapeConfigs[name]; !ok { + sp.stop() + delete(m.scrapePools, name) } } + return nil }