mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
Fix race condition on file SD (#3468)
The file discovery should only stop the watcher if it has been created otherwise it may trigger a segmentation fault.
This commit is contained in:
parent
2881d73ed8
commit
78625f85a7
|
@ -114,14 +114,13 @@ func (d *Discovery) watchFiles() {
|
|||
|
||||
// Run implements the TargetProvider interface.
|
||||
func (d *Discovery) Run(ctx context.Context, ch chan<- []*config.TargetGroup) {
|
||||
defer d.stop()
|
||||
|
||||
watcher, err := fsnotify.NewWatcher()
|
||||
if err != nil {
|
||||
level.Error(d.logger).Log("msg", "Error adding file watcher", "err", err)
|
||||
return
|
||||
}
|
||||
d.watcher = watcher
|
||||
defer d.stop()
|
||||
|
||||
d.refresh(ctx, ch)
|
||||
|
||||
|
|
Loading…
Reference in a new issue