Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: promtail race fixes #12656

Merged
merged 8 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
A few more
  • Loading branch information
paul1r committed Apr 17, 2024
commit 611ceee1344d2553c7f78683b05c7b6f5f7c7bbb
2 changes: 2 additions & 0 deletions clients/pkg/promtail/targets/file/filetarget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ func TestFileTargetSync(t *testing.T) {
err = target.sync()
assert.NoError(t, err)

target.mu.Lock()
if len(target.watches) != 0 {
t.Fatal("Expected watches to be 0 at this point in the test...")
}
if len(target.readers) != 0 {
t.Fatal("Expected tails to be 0 at this point in the test...")
}
target.mu.Unlock()

// Add a file, which should create a watcher and a tailer.
_, err = os.Create(logDir1File1)
Expand Down
4 changes: 4 additions & 0 deletions clients/pkg/promtail/wal/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ var cases = map[string]watcherTest{
// collecting segment 0
res.notifySegmentReclaimed(0)
require.Eventually(t, func() bool {
res.writeTo.mu.Lock()
defer res.writeTo.mu.Unlock()
return len(res.writeTo.ReceivedSeriesReset) == 1 && res.writeTo.ReceivedSeriesReset[0] == 0
}, time.Second*10, time.Second, "timed out waiting to receive series reset")

Expand All @@ -316,6 +318,8 @@ var cases = map[string]watcherTest{
res.notifySegmentReclaimed(2)
// Expect second SeriesReset call to have the highest numbered deleted segment, 2
require.Eventually(t, func() bool {
res.writeTo.mu.Lock()
defer res.writeTo.mu.Unlock()
t.Logf("received series reset: %v", res.writeTo.ReceivedSeriesReset)
return len(res.writeTo.ReceivedSeriesReset) == 2 && res.writeTo.ReceivedSeriesReset[1] == 2
}, time.Second*10, time.Second, "timed out waiting to receive series reset")
Expand Down
Loading