Skip to content
Snippets Groups Projects
Commit 78625f85 authored by pasquier-s's avatar pasquier-s Committed by Brian Brazil
Browse files

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.
parent 2881d73e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment