Implement support for RUN --network=none|default|host#1141
Implement support for RUN --network=none|default|host#1141tonistiigi merged 9 commits intomoby:masterfrom Metaswitch:run-network-mode
Conversation
|
Please sign your commits following these rules: $ git clone -b "run-network-mode" git@github.com:Metaswitch/buildkit.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -fAmending updates the existing PR. You DO NOT need to open a new one. |
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
tonistiigi
left a comment
There was a problem hiding this comment.
@AkihiroSuda @tiborvass @justincormack @thaJeztah
Not quite sure about the --network=default name. Definitely, don't want to call it bridge. Maybe we should call it sandbox like the security mode? Although actually this is just a default that is chosen on daemon startup.
Needs docs update as well. These can wait until the syntax is confirmed.
|
Thanks for the comments @tonistiigi, yeah I didn't write docs for that exact reason, obviously I'll add some before the final merge. |
|
Yeah, the The only concern I'd have with this feature is that it's diverging from how we treated Dockerfiles in the past, where certain options had to be past from the commandline (with the reasoning that a Dockerfile by itself shouldn't be able to gain more privileges than the default). Is this still gated by some command line option? (disclaimer: haven't caught up with the latest changes in this repository) |
@thaJeztah Yes, you can't use @bossmc Regarding command line flags, we should also verify that |
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
|
Ok @tonistiigi, I've applied your review comments (using RunOptions, adding tests that the flag only applies to one command, proper test for hostNetworking support) I've not yet added a test for checking that the command line option is used if the flag is not set, could you give me some pointers for what such a test would look like? |
|
Possible alternative to |
|
@tonistiigi I don't have a problem with |
@bossmc Set "force-network-mode" frontend opt to set the value that cli |
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
|
Hmmm, adding that last test has exposed that I think we might need both "sandbox" and "default/unspecified" - this PR currently implements:
There's no way to overload
But maybe it's weird to allow the Dockerfile to mandate a sandbox network when the client asked to use the host? Which field takes priority here? |
|
If we had |
|
The "sandbox" isn't really guaranteed by buildkit(that's because it does not exist in LLB). It is just a default mode configured by daemon(eg. in buildkitd it is actually host unless cni is configured). I think we should keep "default" (or "unset") and it is the same as passed in |
|
@thaJeztah due to the way @tonistiigi I found that if I set the network to It feels like we're converging on |
I would expect
I think that is the best option. |
|
Ok, sounds like the implementation is doing the right thing (:tm:). I'll write some docs and then I guess this needs one final review? |
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
|
Docs updated, over to you 😄 |
|
Oops, just noticed a bug (in the norunnetwork/norunsecurity code), I'll fix tomorrow. |
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
|
I do not understand the UT failure, I can reproduce it sporadically locally, but I've checked and the LLB definitely doesn't enable host networking for the second |
|
@bossmc What test was failing? |
|
|
That test is covering: With host-networking allowed. |
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
|
The issue with the test is not sure atm what is causing this but it shows up with this patch that makes sure cni is enabled when tests run. Currently, in auto mode it would switch to edit: actually, a better patch would be to always fail daemon on |
|
@AkihiroSuda I believe the issue with the cni initialization is buildkit/util/testutil/integration/oci.go Line 98 in 6885427 |
|
|
|
@AkihiroSuda That's a bit problematic with the current functions because the env are created later inside |
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
tonistiigi
left a comment
There was a problem hiding this comment.
this feature LGTM but we should find some fix for the sudo issue so these tests do not become flaky.
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
tonistiigi
left a comment
There was a problem hiding this comment.
I guess with the BUILDKIT_RUN_NETWORK_INTEGRATION_TESTS protection the sudo problem does not affect this PR anymore as the BUILDKIT_RUN_NETWORK_INTEGRATION_TESTS env is not forwarded either on rootless mode. So we can track that as a follow-up issue.
Signed-off-by: Andy Caldwell <andrew.caldwell@metaswitch.com>
Following a similar pattern to #1081, this adds support in the experimental Dockerfile for
RUNinstructions with customised networking modes:Allowed arguments for
--networkare:none- No networking is available during the invocation (useful for preventing external effects)host- Expose the host's network stack to the invocation (requires thenetwork.hostentitlement)default- The invocation is run in the standard internal network (equivalent to not specifying the network)