-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
pkg/ns README: expand on danger in ns switching in long-lived programs #331
Conversation
This isn't a necessary condition for trouble. Any time the Go runtime creates a new OS thread while the namespace was changed, you can expect some other goroutine to switch to that thread some time later. |
4cb6d6b
to
b1ea5f1
Compare
b1ea5f1
to
8805c93
Compare
Good point, I've re-written this section to focus on that point. That's the "checkmate" aspect of this. It is just totally outside the control of the Go programmer. |
@rosenhouse can you explain the issue a bit more? I'm not quite seeing how a new goroutine that's assigned to the same OS thread as a Do() can execute and do anything until that Do() has reset the netns and exited... I'm very likely missing something :) |
@dcbw @bboreham I put together a rough demo of the problem here. The key part is here: spin up some goroutines on the main thread, and observe if their namespace is as expected. Failures are frequent but random. |
Looks like Weave this issue, again: https://www.weave.works/blog/linux-namespaces-and-go-don-t-mix |
@rosenhouse the ordering was: first Weave hit this issue, then Martynas found the cause, then Bryan came over here to point out it would hit CNI the same way 🙂, then Martynas wrote a blog post, then it sat in a publication queue for months. (Bryan sat next to Martynas at the time) |
This PR LGTM; @dcbw are you satisfied now? |
- redux of containernetworking/cni#331 since the plugin/lib split - added link to new blog post about this from Weave folks (thanks!)
Closing in favor of containernetworking/plugins#14 |
- redux of containernetworking/cni#331 since the plugin/lib split - added link to new blog post about this from Weave folks (thanks!)
cc: @bboreham I realized there was another key point missing in the readme: that long-lived Go processes cannot switch namespaces safely, because even new goroutines may share threads with old goroutines.
Follow up to #330 and #262