-
Notifications
You must be signed in to change notification settings - Fork 373
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 condition in GetCurrentNS temporarily #1131
Conversation
Thanks for your PR. The following commands are available:
|
/test-all |
@antoninbas This should fix the issue too without replacing the module in go.mod, please let me know if it makes sense to you. |
In GetCurrentNS, If there is a context-switch between getCurrentThreadNetNSPath and GetNS, another goroutine may execute in the original thread and change its network namespace, then the original goroutine would get the updated network namespace, which could lead to unexpected behavior, especially when GetCurrentNS is used to get the host network namespace in netNS.Do. Instead of using the provided netns argument, this patch fixes it by getting the hostNS in advance with the OS thread locked.
/test-all |
/test-windows-networkpolicy |
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.
LGTM
if err := ns.WithNetNSPath(containerNetNS, func(hostNS ns.NetNS) error { | ||
|
||
// This is a workaround for issue #1113, which is caused by https://github.com/containernetworking/plugins/issues/524. | ||
// Instead of using the provided netns argument, which might not be the real hostNS, it fixes it by getting the |
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.
it fixes by getting -> this fix gets
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.
@jianjuns I think "it fixes it" is correct here, even though I like your suggestion better. However, since this is your only comment and Quan may have started his weekend, I will merge this and proceed with the 0.9.1 release.
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.
No problem to me.
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.
Just a suggestion for comments.
In GetCurrentNS, If there is a context-switch between getCurrentThreadNetNSPath and GetNS, another goroutine may execute in the original thread and change its network namespace, then the original goroutine would get the updated network namespace, which could lead to unexpected behavior, especially when GetCurrentNS is used to get the host network namespace in netNS.Do. Instead of using the provided netns argument, this patch fixes it by getting the hostNS in advance with the OS thread locked.
In GetCurrentNS, If there is a context-switch between getCurrentThreadNetNSPath and GetNS, another goroutine may execute in the original thread and change its network namespace, then the original goroutine would get the updated network namespace, which could lead to unexpected behavior, especially when GetCurrentNS is used to get the host network namespace in netNS.Do. Instead of using the provided netns argument, this patch fixes it by getting the hostNS in advance with the OS thread locked.
In GetCurrentNS, If there is a context-switch between getCurrentThreadNetNSPath and GetNS, another goroutine may execute in the original thread and change its network namespace, then the original goroutine would get the updated network namespace, which could lead to unexpected behavior, especially when GetCurrentNS is used to get the host network namespace in netNS.Do. Instead of using the provided netns argument, this patch fixes it by getting the hostNS in advance with the OS thread locked.
In GetCurrentNS, If there is a context-switch between getCurrentThreadNetNSPath and GetNS, another goroutine may execute in the original thread and change its network namespace, then the original goroutine would get the updated network namespace, which could lead to unexpected behavior, especially when GetCurrentNS is used to get the host network namespace in netNS.Do. Instead of using the provided netns argument, this patch fixes it by getting the hostNS in advance with the OS thread locked.
In GetCurrentNS, If there is a context-switch between
getCurrentThreadNetNSPath and GetNS, another goroutine may execute in
the original thread and change its network namespace, then the original
goroutine would get the updated network namespace, which could lead to
unexpected behavior, especially when GetCurrentNS is used to get the
host network namespace in netNS.Do.
Instead of using the provided netns argument, this patch fixes it by
getting the hostNS in advance with the OS thread locked.
Fixes #1113