simplify the pool cleanup

This commit is contained in:
Krasi Georgiev 2018-01-14 19:42:31 +00:00
parent a981b51900
commit a535c8d1b4

View file

@ -146,20 +146,15 @@ func (m *ScrapeManager) reload(t map[string][]*targetgroup.Group) error {
} else { } else {
existing.Sync(tgroup) existing.Sync(tgroup)
} }
}
// Cleanup - check the config and cancel the scrape loops if it don't exist in the scrape config. // Cleanup - check the config and cancel the scrape loops if it don't exist in the scrape config.
jobs := make(map[string]struct{}) for name, sp := range m.scrapePools {
if _, ok := m.scrapeConfigs[name]; !ok {
for k := range m.scrapeConfigs { sp.stop()
jobs[k] = struct{}{} delete(m.scrapePools, name)
}
for name, sp := range m.scrapePools {
if _, ok := jobs[name]; !ok {
sp.stop()
delete(m.scrapePools, name)
}
} }
} }
return nil return nil
} }