cli: add configuration option to use or not use host netns#733
cli: add configuration option to use or not use host netns#733WeiZhang555 merged 4 commits intokata-containers:masterfrom
Conversation
|
Hi @caoruidong
|
|
Oh - also, this new option should be displayed in the output of |
2ebbf5d to
53fb135
Compare
790aa23 to
619c56d
Compare
Codecov Report
@@ Coverage Diff @@
## master #733 +/- ##
==========================================
+ Coverage 66.1% 66.26% +0.15%
==========================================
Files 87 87
Lines 10525 10584 +59
==========================================
+ Hits 6958 7013 +55
+ Misses 2868 2866 -2
- Partials 699 705 +6 |
|
Actually config.NetNSPath will influence both shim and VM processes. I have changed commit msg. But this doesn't work for CNM model. Because we scan endpoints by default and try to attach them, this will break host networking. And libnetwork hook will get a error |
bergwolf
left a comment
There was a problem hiding this comment.
@caoruidong Did you try it with docker? I'm afraid it might do damage to host network (due to the oci hooks), if someone sets DisableNewNetNs and run it with docker.
cli/network.go
Outdated
| err error | ||
| ) | ||
| if config.DisableNewNetNs { | ||
| n, err = ns.GetNS("/proc/1/ns/net") |
There was a problem hiding this comment.
Please use /proc/self/ns/net instead.
Or we can simply not to setup network namespace when DisableNewNetNs is set, in which case we can avoid setupNetworkNamespace() in kata cli and sandbox createNetwork()/removeNetwork().
There was a problem hiding this comment.
Great! I have tried ns.GetCurrentNs() but forgot "/proc/self/ns/net".
I think it's better to skip setupNetworkNamespace(). Let's hear from others.
|
This can be treated as an advanced feature and can only be enabled by users who really understand what this option means, I think if user want to use docker libnetwork, they should keep this flag disabled, and only enable it when they want to do custom operations for network. Based on this, I suggest we make a conflict rule:
According to rule, any violation should got an error. |
|
Sounds good to me but let's also get input from @sboeuf, @amshinde, @mcastelino. |
|
@bergwolf I have tried it with docker. I think it doesn't break host network but gets an error |
|
@mcastelino Yes, --net=host has been diasbled explicitly, explicitly showing an error that this is not supported. @caoruidong Is this feature for your custom networking?
I agree with the error scenarios @WeiZhang555 pointed out. In addition, I think It would be a good idea to skip running the hooks altogether when |
|
@caoruidong based on input from @WeiZhang555 and @bergwolf , I think we need to add some documentation as part of this PR. Last thing, I would greatly appreciate if you could explain clearly the use case for such thing, since this is going against what we've been doing in Kata, and unless we have a strong use case for it, I don't know if we want it. |
|
@mcastelino It is documented in https://github.com/kata-containers/documentation/blob/master/Limitations.md#docker---net=host. |
@amshinde I'm not sure if there will be any new scenario depending on hook support in addition to "docker libnetwork", so maybe it's not good idea to disable hooks. |
0e34cfc to
57b40ca
Compare
| # macvtap. | ||
| # | ||
| # - none | ||
| # Used when customize network. Only creates a tap device. No veth pair. |
There was a problem hiding this comment.
I think it would be useful to add a link here to the following as that shows users visually more about how this will work:
There was a problem hiding this comment.
OK. I will add a PR in documentation repo.
214ffd1 to
1482f03
Compare
|
@bergwolf Comments addressed in this PR. |
15430c9 to
0971987
Compare
Refactor these functions so differernt types of endpoints can use a unified function to hotplug nics. Fixes kata-containers#731 Signed-off-by: Ruidong Cao <caoruidong@huawei.com>
…point This model is for not creating a new net ns for VM and directly creating taps in the host net ns. Signed-off-by: Ruidong Cao <caoruidong@huawei.com>
If `disable_new_netns` set to true, create VM and shim processes in the host netns Signed-off-by: Ruidong Cao <caoruidong@huawei.com>
Add unit test for `disable_new_netns` Signed-off-by: Ruidong Cao <caoruidong@huawei.com>
|
@caoruidong ping from your weekly Kata herder. Doing re-test? |
sboeuf
left a comment
There was a problem hiding this comment.
Thanks @caoruidong for all the reworks :)
LGTM
|
/test |
If
disable_new_netnsset to true, create VM and shim processes in the host netnsFixes #731
Signed-off-by: Ruidong Cao caoruidong@huawei.com