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

Need to move pod network setup out of process #15991

Closed
danwinship opened this issue Aug 25, 2017 · 3 comments · Fixed by #18355
Closed

Need to move pod network setup out of process #15991

danwinship opened this issue Aug 25, 2017 · 3 comments · Fixed by #18355
Assignees
Labels
component/networking kind/bug Categorizes issue or PR as related to a bug. priority/P2

Comments

@danwinship
Copy link
Contributor

Apparently, it is impossible to reliably work with network namespaces in a long-running golang process because the goroutine scheduler's shenanigans are incompatible with APIs that set current-thread state; calling ns.Set() or ns.Do() may cause other goroutines to change their current namespace as well. (eg, containernetworking/cni#262, https://www.weave.works/blog/linux-namespaces-and-go-don-t-mix)

I don't know of any bugs we've seen that would be explained by our getting this wrong, but it seems likely that there must be some, and if not there eventually will be.

So we need to move at least half of pod_linux.go over to sdn-cni-plugin... Basically, we probably don't want to import any of the CNI packages into the openshift binary. The OVS-manipulating parts of pod_linux.go would probably stay in the openshift binary.

@pweil- pweil- added kind/bug Categorizes issue or PR as related to a bug. priority/P2 labels Aug 28, 2017
@dcbw
Copy link
Contributor

dcbw commented Aug 28, 2017

@danwinship summary of our discussion on IRC...

Using netns stuff in the same process is OK as long as all the code is properly using Do() or WithNetNSPath(). All the pod* stuff does that, but the concern is other code in Kubernetes/OpenShift that always expects to be run in the host's netns. If an OS thread is created by the Go runtime while some goroutine is in a container's netns, that OS thread will be created in the container's netns even though it is completely unrelated to netns-manipulating code. Later, any code that runs in that new OS thread will not be running in the netns it probably expects.

Any code that does something network related should be setting the netns before running that code. Obviously that's somewhat hard as we don't/can't control all the code, nor vendor code.

So yes, to completely ensure that this won't be a problem, the netns-using code should get moved. That will be somewhat complicated though, and given we haven't run into this issue much (if at all?) in OpenShift yet, perhaps this could be an RFE for now.

@danwinship
Copy link
Contributor Author

@dcbw it looks like this does happen sometimes: #14385 (comment)

@danwinship
Copy link
Contributor Author

Ugh. It looks like this happens a lot.

In the last few weeks of post-commit extended networking tests:

In the last one week of extended_networking_minimal tests running against PRs:

openshift-merge-robot added a commit that referenced this issue Feb 2, 2018
Automatic merge from submit-queue (batch tested with PRs 18376, 18355).

Move pod-namespace calls out of process

As discussed in #15991, we need to move all operations in the pod's network namespace out of process, due to a golang issue that allows setns() calls in a locked thread to leak into other threads, causing random lossage as operations intended for the main network namespace end up running in other namespaces instead. (This is fixed in golang 1.10 but we need a fix before then.)

Fixes #15991
Fixes #14385
Fixes #13108
Fixes #18317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/networking kind/bug Categorizes issue or PR as related to a bug. priority/P2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants