-
Notifications
You must be signed in to change notification settings - Fork 264
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 race in syscallWatcher #431
Conversation
Signed-off-by: Yechiel Kalmenson <ykalmenson@pivotal.io>
Thank you this is great! |
LGTM. @kevpar - PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple comments but overall LGTM.
internal/hcs/watcher.go
Outdated
// go syscallWatcher(context, &completed) | ||
// <syscall> | ||
// completed = true | ||
// sysycallWatcher(logContext, func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo "sysycall"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, fixed :)
|
||
func watchFunc(ctx context.Context, logContext logrus.Fields) { | ||
select { | ||
case <-ctx.Done(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a select statement here, since there is only one case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct that with a single case the code can be written inline. But this is a golang pattern so it doesn't bother me either way. Up to you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the pattern we've seen in the documentation. Let up know if you want us to change it.
Many transitive dependencies have been updated. This update includes our [PR](microsoft/hcsshim#431) to the syscall watcher All the tests pass with no major API changes Signed-off-by: Arjun Sreedharan <asreedharan@pivotal.io>
Uses greenhouse-org/hcsshim, branch upstream-v0.8.5-mod. This contains all commits from Microsoft/hcsshim v.0.8.5 + commits made by our team to the fork. Many transitive dependencies have been updated. This update includes our PR (microsoft/hcsshim#431) to the syscall watcher All the tests pass with no major API changes Signed-off-by: Arjun Sreedharan <asreedharan@pivotal.io>
Uses greenhouse-org/hcsshim, branch upstream-v0.8.5-mod. This contains all commits from Microsoft/hcsshim v.0.8.5 + commits made by our team to the fork. Many transitive dependencies have been updated. This update includes our PR (microsoft/hcsshim#431) to the syscall watcher All the tests pass with no major API changes Signed-off-by: Arjun Sreedharan <asreedharan@pivotal.io>
Fix race in syscallWatcher
This PR fixes two issues:
If the syscallWatcher function is started in a goroutine, the goroutine remains around for the length of
timeout.SyscallWatcher
(4 minutes). So a longrunning process can accumulate goroutines if it makes many syscalls that use the syscallWatcher in a 4 minute span.There is a race condition where both the syscallWatcher goroutine and the main function access the
completed
variable. This will cause any test suites that:go test -race
to fail due to the race detector. An easy way to reproduce is:
This PR fixes the issue by using a context.Context object to handle the timeout
Signed-off-by: Yechiel Kalmenson ykalmenson@pivotal.io