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

Tests: Attempt to fix flaky test in reloader on directories changes #4765

Merged
merged 2 commits into from
Oct 12, 2021

Conversation

matej-g
Copy link
Collaborator

@matej-g matej-g commented Oct 11, 2021

Signed-off-by: Matej Gera matejgera@gmail.com

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

We've been seeing some increase in failures for TestReloader_DirectoriesApply recently (see e.g. this CI run). Although there were other fixes for the test (#3798), it looks like this is not directly related to the previously discovered issues.

According to the output, the test seems to skip step 1 from among the steps required to be run to manipulate rule files, leading to incorrect number of watch events:

--- FAIL: TestReloader_DirectoriesApply (2.52s)
    reloader_test.go:278: Performing step number 0
    reloader_test.go:278: Performing step number 2
    reloader_test.go:278: Performing step number 3
    reloader_test.go:278: Performing step number 4
    reloader_test.go:278: Performing step number 5
    reloader_test.go:365: reloader_test.go:365:
        
        	exp: 6
        
        	got: 5
        
        
FAIL
FAIL	github.com/thanos-io/thanos/pkg/reloader	5.280s

After more investigation, I have established that this is due to a 'race' between the reloader and the goroutine executing the steps. On an occasion, the reloader can invoke the reload handler two times while the step executing goroutine did not have time to catch up with the reloader. This causes the step execution loop to skip ahead to get on the same number of reloads as the reloader and thus not executing the step in between. The suggestion in this PR is to have mechanism to check these skips and 'catch up' with the reloader if that happens.

Verification

Run a modified test locally with extra output confirming the skipped steps are executed, if such a skip occurs in the test run.

Signed-off-by: Matej Gera <matejgera@gmail.com>
onprem
onprem previously approved these changes Oct 11, 2021
Copy link
Member

@onprem onprem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you for fixing this, it has caused a lot of pain.

Just one non-blocking comment.

pkg/reloader/reloader_test.go Show resolved Hide resolved
Signed-off-by: Matej Gera <matejgera@gmail.com>
Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

@GiedriusS GiedriusS merged commit 7dee6fa into thanos-io:main Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants