mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-04 20:06:12 +02:00
scrape: fix race between SetScrapeFailureLogger and restartLoops
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
This commit is contained in:
parent
320901614e
commit
387d3ea851
@ -391,23 +391,24 @@ func (m *Manager) ApplyConfig(cfg *config.Config) error {
|
||||
wg.Done()
|
||||
<-canReload
|
||||
}()
|
||||
switch {
|
||||
case !ok:
|
||||
if !ok {
|
||||
sp.stop()
|
||||
toDelete.Store(name, struct{}{})
|
||||
case !reflect.DeepEqual(sp.config, cfg):
|
||||
return
|
||||
}
|
||||
// Update the scrape failure logger before reloading so that
|
||||
// restartLoops captures the new logger when starting new loops.
|
||||
if l, ok := m.scrapeFailureLoggers[cfg.ScrapeFailureLogFile]; ok {
|
||||
sp.SetScrapeFailureLogger(l)
|
||||
} else {
|
||||
sp.logger.Error("No logger found. This is a bug in Prometheus that should be reported upstream.", "scrape_pool", name)
|
||||
}
|
||||
if !reflect.DeepEqual(sp.config, cfg) {
|
||||
err := sp.reload(cfg)
|
||||
if err != nil {
|
||||
m.logger.Error("error reloading scrape pool", "err", err, "scrape_pool", name)
|
||||
failed.Store(true)
|
||||
}
|
||||
fallthrough
|
||||
case ok:
|
||||
if l, ok := m.scrapeFailureLoggers[cfg.ScrapeFailureLogFile]; ok {
|
||||
sp.SetScrapeFailureLogger(l)
|
||||
} else {
|
||||
sp.logger.Error("No logger found. This is a bug in Prometheus that should be reported upstream.", "scrape_pool", name)
|
||||
}
|
||||
}
|
||||
}(poolName, pool, cfg, ok)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user