mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
move cleanup and reload in ApplyConfig
This commit is contained in:
parent
719c579f7b
commit
910c22418c
|
@ -15,6 +15,7 @@ package retrieval
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
|
@ -84,6 +85,17 @@ func (m *ScrapeManager) ApplyConfig(cfg *config.Config) error {
|
||||||
c[scfg.JobName] = scfg
|
c[scfg.JobName] = scfg
|
||||||
}
|
}
|
||||||
m.scrapeConfigs = c
|
m.scrapeConfigs = c
|
||||||
|
|
||||||
|
// Cleanup and reload pool if config has changed.
|
||||||
|
for name, sp := range m.scrapePools {
|
||||||
|
if cfg, ok := m.scrapeConfigs[name]; !ok {
|
||||||
|
sp.stop()
|
||||||
|
delete(m.scrapePools, name)
|
||||||
|
} else if !reflect.DeepEqual(sp.config, cfg) {
|
||||||
|
sp.reload(cfg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,12 +153,4 @@ func (m *ScrapeManager) reload(t map[string][]*targetgroup.Group) {
|
||||||
existing.Sync(tgroup)
|
existing.Sync(tgroup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue