Skip to content

gvisor: init at 2019-11-14#73097

Merged
flokli merged 3 commits intoNixOS:masterfrom
andrew-d:andrew/gvisor-redux
Dec 5, 2019
Merged

gvisor: init at 2019-11-14#73097
flokli merged 3 commits intoNixOS:masterfrom
andrew-d:andrew/gvisor-redux

Conversation

@andrew-d
Copy link
Copy Markdown
Contributor

@andrew-d andrew-d commented Nov 9, 2019

Motivation for this change

This is a revamp of #50218 after enough upstream changes that it's possible to build inside a Nix sandbox. This was requested in #39889, but there were some problems with Bazel at the time. I've managed to get this working with buildBazelPackage. At the end of the whole process, gvisor is runnable:

$ /nix/store/7k1c1jikms1pjimk8561x18xpj51dm5l-gvisor-2019-11-08/bin/runsc --help
Usage: runsc <flags> <subcommand> <subcommand args>

Subcommands:
	checkpoint       checkpoint current state of container (experimental)
	create           create a secure container
	delete           delete resources held by a container
	do               Simplistic way to execute a command inside the sandbox. It's to be used for testing only.
	events           display container events such as OOM notifications, cpu, memory, and IO usage statistics

(I also added the containerd shim as well, since it didn't feel worth another PR)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc original reviewers @nlewo, @Profpatsch, and commenters @dtzWill, @benpye and @ghuntley

Closes #50218
Closes #39889

@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Nov 9, 2019
@ofborg ofborg bot requested a review from kalbasit November 9, 2019 08:13
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Nov 9, 2019
@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch from 39b32fd to fc15db2 Compare November 9, 2019 08:24
@Profpatsch
Copy link
Copy Markdown
Member

Do you have sandboxing enabled in your local nix? The build fails, because it tries to download some repository dependencies. Most of the nix world has sandboxing enabled, which restricts network access to fixed-output derivations.

@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch from fc15db2 to 6448357 Compare November 22, 2019 08:04
@andrew-d
Copy link
Copy Markdown
Contributor Author

@Profpatsch - I do, yes. I think the problem is that the buildBazelPackage tools remove rules_cc, which is now an external dependency and then can't be downloaded. There's also some issues with rules_go and x/net/nettest that I'm trying to debug as well.

@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch 2 times, most recently from e79b2a1 to 593b61d Compare November 25, 2019 00:32
@andrew-d
Copy link
Copy Markdown
Contributor Author

@Profpatsch - Okay, between #74013 and this PR, it's building successfully and reproducibly 🎉

@flokli
Copy link
Copy Markdown
Member

flokli commented Nov 26, 2019

Can you add a simple nixos vm test starting a container, so we can verify it works?

@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch from 593b61d to 726559a Compare November 27, 2019 07:02
@andrew-d
Copy link
Copy Markdown
Contributor Author

@flokli - Okay, added a test that exercises both the gvisor do subcommand and gvisor when it's being used as a Docker runtime. I hadn't previously tested the gvisor do subcommand, so I also added a patch to ensure that the path to ip/ipconfig/sysctl is absolute.

@ofborg ofborg bot added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Nov 27, 2019
@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch from 726559a to 34344de Compare November 28, 2019 04:04
@andrew-d
Copy link
Copy Markdown
Contributor Author

@Profpatsch / @flokli - Okay, rebased now that #74103 is merged. This should be ready to merge now, and tests pass locally.

@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch from 34344de to ba2e010 Compare November 28, 2019 04:55
@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch 2 times, most recently from a852a36 to eddf8c2 Compare November 28, 2019 23:58
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.

For the sake of maintainability:

Could we just do a wrapProgram $out/bin/runsc --prefix PATH : ${stdenv.lib.makeBinPath [ iproute iptables procps ]} in installPhase, instead of patching the source code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@flokli - Done! And confirmed that it works in the NixOS test as well.

@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch from eddf8c2 to 903eba6 Compare December 4, 2019 07:17
@andrew-d andrew-d force-pushed the andrew/gvisor-redux branch from 903eba6 to c37902d Compare December 4, 2019 07:55
@andrew-d andrew-d changed the title gvisor: init at 2019-11-08 gvisor: init at 2019-11-14 Dec 4, 2019
@andrew-d
Copy link
Copy Markdown
Contributor Author

andrew-d commented Dec 4, 2019

I also just bumped to an actual tagged release of gvisor, since they tagged release-20191114.0 after I'd opened this PR.

@flokli flokli merged commit 3140fa8 into NixOS:master Dec 5, 2019
@flokli
Copy link
Copy Markdown
Member

flokli commented Dec 5, 2019

Thanks!

dtzWill pushed a commit to dtzWill/nixpkgs that referenced this pull request Dec 5, 2019
gvisor: init at 2019-11-14
(cherry picked from commit 3140fa8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

package request/idea: gvisor

3 participants