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

checks: wait for goroutine to complete (fix go-test-race failures) #8346

Merged
merged 1 commit into from
Jul 21, 2020

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Jul 20, 2020

Fixes #8329 (comment)

CheckAlias already had a WaitGroup, but the Add() call was happening too late, which was causing a race in tests. The add must happen before the goroutine is started.

CheckHTTP did not have a WaitGroup, so I added it to match CheckAlias.

It looks like CheckTCP, CheckMonitor, CheckDocker, CheckGRPC, and CheckTTL all may have the same problem. I'm not sure why it seems that only alias and http are failing. I saw one failure for GRPC, so maybe alias and http happen to have more tests written for them?

If this fix looks good, I will look at refactoring so that all of these can share the "run" mechanism and remove the need to copy the fix 7 times.

CheckAlias already had a waitGroup, but the Add() call was happening too late, which was causing a race in tests. The add must happen before the goroutine is started.

CheckHTTP did not have a waitGroup, so I added it to match CheckAlias.

It looks like a lot of the implementation could be shared, and may not need all of channel, waitgroup and bool, but I will leave that refactor for another time.
@dnephin
Copy link
Contributor Author

dnephin commented Jul 20, 2020

The remaining failure in go-test-race is documented here: #8329 (comment). Seems to be a similar cause, but will require a different fix.

Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

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

LGTM

@dnephin dnephin merged commit 2c306e4 into master Jul 21, 2020
@dnephin dnephin deleted the dnephin/fix-race-in-agent-checks branch July 21, 2020 15:57
@dnephin dnephin mentioned this pull request Jul 21, 2020
10 tasks
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.

ci: Run unit tests with -race
2 participants