Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

cli: add configuration option to use or not use host netns#733

Merged
WeiZhang555 merged 4 commits intokata-containers:masterfrom
caoruidong:qemu-ns
Oct 24, 2018
Merged

cli: add configuration option to use or not use host netns#733
WeiZhang555 merged 4 commits intokata-containers:masterfrom
caoruidong:qemu-ns

Conversation

@caoruidong
Copy link
Copy Markdown
Member

@caoruidong caoruidong commented Sep 14, 2018

If disable_new_netns set to true, create VM and shim processes in the host netns

Fixes #731

Signed-off-by: Ruidong Cao caoruidong@huawei.com

@jodh-intel
Copy link
Copy Markdown

Hi @caoruidong

  • This will be useful for tracing the agent (Adding OpenTracing support for Kata kata-containers#27), so thanks for raising! 😄
  • Your branch has conflicts so please rebase.
  • Please could you add a unit test for this new option.
  • The issues in your "Fixes" comment mentions disabling the ns for the shim too, but the code only applies to the hypervisor.

@jodh-intel
Copy link
Copy Markdown

Oh - also, this new option should be displayed in the output of kata-env ideally (remember to increase the value of formatVersion in kata-env.go).

@sboeuf sboeuf added the enhancement Improvement to an existing feature label Sep 14, 2018
@caoruidong caoruidong changed the title cli: add configuration option to enable/disable hypervisor in host netns cli: add configuration option to use or not use host netns Sep 14, 2018
@caoruidong caoruidong force-pushed the qemu-ns branch 2 times, most recently from 2ebbf5d to 53fb135 Compare September 15, 2018 03:57
@caoruidong caoruidong force-pushed the qemu-ns branch 2 times, most recently from 790aa23 to 619c56d Compare September 15, 2018 06:55
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 15, 2018

Codecov Report

Merging #733 into master will increase coverage by 0.15%.
The diff coverage is 37.16%.

@@            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

@caoruidong
Copy link
Copy Markdown
Member Author

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 failed to set gateway while updating gateway: network is unreachable.
So just works with docker run -it --net=none

@caoruidong caoruidong removed the wip label Sep 15, 2018
Copy link
Copy Markdown
Member

@bergwolf bergwolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jodh-intel jodh-intel added the feature New functionality label Sep 17, 2018
@WeiZhang555
Copy link
Copy Markdown
Member

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:

  • disable_new_netns conflicts with enable_netmon
  • disable_new_netns conflicts with internetworking_model=bridge and internetworking_model=macvtap, instead we add a new network model none. disable_new_netns works only with internetworking_model=none

According to rule, any violation should got an error.

@jodh-intel
Copy link
Copy Markdown

Sounds good to me but let's also get input from @sboeuf, @amshinde, @mcastelino.

@caoruidong
Copy link
Copy Markdown
Member Author

@bergwolf I have tried it with docker. I think it doesn't break host network but gets an error failed to set gateway while updating gateway: network is unreachable. due to hook.
It works with --net=none

@mcastelino
Copy link
Copy Markdown
Contributor

@sboeuf @amshinde I am surprised that --net=host did not cause any issues. Did you add new code that disabled networking when --net=host is setup? I understand --net=none working.

@amshinde
Copy link
Copy Markdown
Member

@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?

disable_new_netns conflicts with enable_netmon
disable_new_netns conflicts with internetworking_model=bridge and internetworking_model=macvtap, instead we add a new network model none. disable_new_netns works only with internetworking_model=none

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 disable_new_netns is true.

@sboeuf
Copy link
Copy Markdown

sboeuf commented Sep 17, 2018

@caoruidong based on input from @WeiZhang555 and @bergwolf , I think we need to add some documentation as part of this PR.
Because this option should only be used by ppl who know what they're doing, please add both documentation in the code and into a .md file.

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.

@caoruidong
Copy link
Copy Markdown
Member Author

@mcastelino It is documented in https://github.com/kata-containers/documentation/blob/master/Limitations.md#docker---net=host.
This is kind of custom use case, but originally comes from what we discuss in #113 (comment). Thanks to gnawux, he draws a picture #113 (comment).
I will add some documents after we reach a consensus.

@WeiZhang555
Copy link
Copy Markdown
Member

I think It would be a good idea to skip running the hooks altogether when disable_new_netns is true.

@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.

@caoruidong caoruidong force-pushed the qemu-ns branch 3 times, most recently from 0e34cfc to 57b40ca Compare September 20, 2018 10:56
# macvtap.
#
# - none
# Used when customize network. Only creates a tap device. No veth pair.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I will add a PR in documentation repo.

@caoruidong caoruidong force-pushed the qemu-ns branch 3 times, most recently from 214ffd1 to 1482f03 Compare October 19, 2018 03:29
@caoruidong
Copy link
Copy Markdown
Member Author

@bergwolf Comments addressed in this PR.

@jshachm
Copy link
Copy Markdown
Member

jshachm commented Oct 22, 2018

LGTM , and waiting for that we fix the strange error of CI.

Approved with PullApprove

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>
@raravena80
Copy link
Copy Markdown
Member

@caoruidong ping from your weekly Kata herder. Doing re-test?

@caoruidong
Copy link
Copy Markdown
Member Author

@amshinde @sboeuf branch update

Copy link
Copy Markdown

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @caoruidong for all the reworks :)
LGTM

@caoruidong
Copy link
Copy Markdown
Member Author

/test

@WeiZhang555
Copy link
Copy Markdown
Member

WeiZhang555 commented Oct 24, 2018

LGTM.

As we got 4 LGTMs, I'll merge this now.
The design has been discussed a lot so I think it's safe to merge, we can keep improving detail implementation later.

Approved with PullApprove

@WeiZhang555 WeiZhang555 merged commit 5a8b738 into kata-containers:master Oct 24, 2018
@caoruidong caoruidong deleted the qemu-ns branch October 24, 2018 06:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement Improvement to an existing feature feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants