Skip to content
Snippets Groups Projects
Commit bb89b9b5 authored by Edward Welch's avatar Edward Welch Committed by Ed
Browse files

Fix a bug where we should use the glob matcher on fsnotify new file create.

Changed the timing of the sync function in the unit test to fix flakiness in the test.
parent e6503a5c
No related branches found
No related tags found
No related merge requests found
......@@ -132,8 +132,8 @@ func TestPromtail(t *testing.T) {
t.Fatal("Could not delete a log file to verify metrics are removed: ", err)
}
// Sync period is 100ms in tests, need to wait for at least one sync period for tailer to be cleaned up
<-time.After(150 * time.Millisecond)
// Sync period is 500ms in tests, need to wait for at least one sync period for tailer to be cleaned up
<-time.After(500 * time.Millisecond)
//Pull out some prometheus metrics before shutting down
metricsBytes, contentType := getPromMetrics(t)
......@@ -497,7 +497,9 @@ func buildTestConfig(t *testing.T, positionsFileName string, logDirName string)
}
cfg.ScrapeConfig = append(cfg.ScrapeConfig, scrapeConfig)
cfg.TargetConfig.SyncPeriod = 10 * time.Millisecond
// Make sure the SyncPeriod is fast for test purposes, but not faster than the poll interval (250ms)
// to avoid a race between the sync() function and the tailers noticing when files are deleted
cfg.TargetConfig.SyncPeriod = 500 * time.Millisecond
return cfg
}
......
......@@ -163,7 +163,7 @@ func (t *FileTarget) run() {
case event := <-t.watcher.Events:
switch event.Op {
case fsnotify.Create:
matched, err := filepath.Match(t.path, event.Name)
matched, err := doublestar.Match(t.path, event.Name)
if err != nil {
level.Error(t.logger).Log("msg", "failed to match file", "error", err, "filename", event.Name)
continue
......
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