Commit Graph
77 Commits
Author SHA1 Message Date
Zach KoopmansandgVisor bot bda81b139c Update docker packages to new moby repo.
PiperOrigin-RevId: 555358714
2023-08-09 20:48:47 -07:00
Nicolas LacasseandgVisor bot 78be58e783 Partial rollback of cl/522685544.
To re-enable hostinet tests that require CAP_NET_RAW and CAP_NET_ADMIN.

PiperOrigin-RevId: 526701516
2023-04-24 11:20:47 -07:00
Nicolas LacasseandgVisor bot c19ef4fb19 Automated rollback of changelist 523138695
PiperOrigin-RevId: 523233101
2023-04-10 15:53:54 -07:00
Nicolas LacasseandgVisor bot 964e4caa71 Apply net-related sysctls when configuring host network.
This is needed to support things like ipv6, which are configured by sysctls
passed to Docker.

PiperOrigin-RevId: 523138695
2023-04-10 09:49:09 -07:00
Nicolas LacasseandgVisor bot c07dc2673f Implement hostinet.Stack methods that manipulate interfaces and addresses.
And enable all of the netlink tests that depend on this functionality.

Specifially, this CL implements hostinet.stack:
* .RemoveInterface()
* .AddInterfaceAddr()
* .RemoveInterfaceAddr()

Applications use netlink messages to call into these methods. For hostinet, we
use netlink messages to the host to implement these methods.

Note that the netlink messages are not simple passed from the application to
the host -- they are parsed first and only carefully crafted messages are sent
to the host.

This CL required a lot of refactoring to the existing netlink code in the
hostinet package, as well as a bunch of new functionality. All of that code has
been collected in hostinet/netlink.go

I also changed how we handle CAP_NET_ADMIN and CAP_NET_RAW in tests, since we
must drop those capabilities inside the sandbox if we don't have them on the
host. The new solution is cleaner and does not rely on google-specific env
variables.

PiperOrigin-RevId: 522685544
2023-04-07 14:33:21 -07:00
Zach KoopmansandgVisor bot b10d68072b Add portforward command to runsc
Add portforward comand so that we can use runsc to forward connections
to container ports. This will eventually be supported in k8s.

PiperOrigin-RevId: 520739913
2023-03-30 14:16:19 -07:00
Ayush RanjanandgVisor bot 8a167a5f72 Prepare to make root overlay the default.
We plan on making --overlay2=root:self the default for runsc. That will be a
risky change which might need rollbacks. This change is in preparation for
that. We manually set --overlay2=none in places where we don't want the
overlay configuration to impact. This change should be a noop. The intention
for this change is to make the risky change very small and limited to just
flipping a flag.

PiperOrigin-RevId: 513930702
2023-03-04 00:46:47 -08:00
Nicolas LacasseandgVisor bot 704b8d9ee8 hostinet: Support ping and raw sockets.
PiperOrigin-RevId: 513902015
2023-03-04 00:40:01 -08:00
Adin ScannellandgVisor bot 2911d8c3b8 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Nicolas LacasseandgVisor bot 42fd695098 runsc requires CAP_NET_RAW with network=host and raw sockets enabled.
We must have CAP_NET_RAW to create raw sockets with hostinet. This change makes
the runsc Loader fail if hostinet+raw sockets are configured but we do not have
the necessary capability.

PiperOrigin-RevId: 513417124
2023-03-01 20:17:37 -08:00
Zach KoopmansandgVisor bot d2e2b3730e Add usage benchmarks
Add the usage benchmark which queries memory usage from the container. This
is meant to replace the size benchmark which has a ton of noise.

Flakes are due to the complicated measurement technique of dropping caches ->
parse /proc/meminfo -> start containers -> drops caches again -> parse
/proc/meminfo -> take the diference. This was done because not all runtimes
support docker/containerd stats.

Buuuut...gVisor does, so we'll just take the stats figures to reduce noise
for the memory usage benchmark.

In addition, the returned types.StatsJSON object contains several useful stats
like page faults and CPU usage, so adding these will be trivial and will not
slow down benchmark performance.

[types.StatsJSON linky link](https://github.com/moby/moby/blob/42c8b314993e5eb3cc2776da0bbe41d5eb4b707b/api/types/stats.go#LL153)

PiperOrigin-RevId: 503342363
2023-01-19 21:00:49 -08:00
Ayush RanjanandgVisor bot 7c1d3983e3 Remove remaining references to vfs2.
PiperOrigin-RevId: 493998299
2022-12-08 14:37:43 -08:00
329def4002 Add overlay2 flag in runsc.
--overlay2 flag supersedes --overlay flag. It allows more granular
configuration for overlayfs in runsc. It does so in two ways:

1. Allows to apply overlay on all mounts or only the root mount.
   --overlay applies overlay to all mounts.
2. Allows to specify if overlay's upper layer should be backed by
   container memory or disk. --overlay always used container memory.

Allowing tmpfs to be backed by a file on disk prevents the container
memory from bloating up. Note that the tmpfs filesystem tree will
still be stored in sentry memory.

Using overlay on the root filesystem, helps avoid expensive
communication with the gofer process. The root filesystem of the
container is not preserved across container lifecycle. So we don't
need to keep updating the host filesystem, which will anyways be
destroyed once the container is destroyed. It is wasted effort.
Instead we keep all the changes to the root filesystem in tmpfs which
is directly accessible by the sentry.

The host file is created as an unnamed file using O_TMPFILE. Support
has been added for sub-containers too. Save/restore support is
still lacking.

Co-authored-by: Andrei Vagin <[email protected]>
PiperOrigin-RevId: 491988485
2022-11-30 12:29:14 -08:00
Kevin KrakauerandgVisor bot 3a76efe831 convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Etienne PerotandgVisor bot 5f5cc82fe1 Use runc as default runtime for unsandboxed containers.
Without this, attempting to build or test gVisor on machines where the default
runtime isn't `runc` may fail, as that runtime may not support what we need.

PiperOrigin-RevId: 486205081
2022-11-04 12:35:05 -07:00
Fabricio VoznikaandgVisor bot 7a5e2b08c9 Allow fsgofer to open character files
Closes #7007

PiperOrigin-RevId: 486008125
2022-11-03 16:54:01 -07:00
Nicolas LacasseandgVisor bot dfa640b44e Append ".txt" to test debug log names.
PiperOrigin-RevId: 476495387
2022-09-23 17:16:27 -07:00
Etienne PerotandgVisor bot 726ebd533d Runtime tests: Add flakiness detection and per-test timeout options.
This adds flags and env variables for the following settings to runtime tests:

- `per_test_timeout`: A per-test timeout which can be shorter
  than the batch timeout. Useful to cap the duration of tests
  which flake by getting stuck (as is the case for
  `bug60120.phpt`)
- `runs_per_test`: Number of times to run each test (useful to
  detect flakes).
- `flaky_is_error`: Controls whether a flaky test is considered
  passing or failing for batch error code purposes. Useful when
  either diagnosing a flaky test, or diagnosing a
  consistently-failing test while bypassing flaky others.
- `flaky_short_circuit`: If a test is found to be flaky, declare
  it as such immediately, rather than waiting for the rest of the
  `--runs_per_test` to finish. Speeds up bisecting flaky test, at
  the cost of flakiness percentage accuracy.

PiperOrigin-RevId: 466791296
2022-08-10 14:50:32 -07:00
Kevin KrakauerandgVisor bot 5ab62d080e Limit the number of open files per sandbox
Fixes #6547.

PiperOrigin-RevId: 457594490
2022-06-27 16:41:21 -07:00
Etienne PerotandgVisor bot c2b3a605ba integration_test: Ensure Docker has experimental features enabled.
This test relies on `docker checkpoint`, which requires experimental
features to be turned on in Docker.

PiperOrigin-RevId: 454246068
2022-06-10 14:49:01 -07:00
Andrei VaginandgVisor bot aaf2247a97 test/runtime: add the timeout option for proctor
proctor is running in a sandbox and it executes tests. If it is able to
handle timeouts, we will know that a test sandbox is alive and proctor
will send SIGTERM to test processes and collect all logs.

In addition, these changes contains a few things:
* upload runsc logs with other test artifacts.
* increase log level for java tests.
* call Fatalf instead of Errorf when we want to terminate a test.

PiperOrigin-RevId: 437385756
2022-03-25 19:38:39 -07:00
Lucas ManningandgVisor bot 48ef47b8dd Add systemd-cgroup support to runsc.
This change adds systemd-cgroup support to cgroupv2 and modifies existing
cgroup tests for systemd support.

Fixes #193

PiperOrigin-RevId: 435457762
2022-03-17 15:03:44 -07:00
Fabricio VoznikaandgVisor bot 40ea07b809 Remove VFS2 test dimension
The default is VFS2 enabled, so the tests setting VFS2 are redundant.

Updates #1624

PiperOrigin-RevId: 431827013
2022-03-01 18:59:30 -08:00
Adin ScannellandgVisor bot 4b3911824d Validate flags during install.
First, this change moves the internal config API to use flag.FlagSet, which
allows more flexibility and fixes many test usages.

Second, the runtime flags are validated during install. The platform is opened
and a warning issued if this fails, but this is not fatal.

This change requires moving the Makefile to --test_env, since the attribute
is not properly supported by test targets. Therefore, the targets can use args
while the Makefile must pass in configuration via --test_env.

PiperOrigin-RevId: 428048274
2022-02-11 11:24:01 -08:00
Adin ScannellandgVisor bot e52546f46f Support STAGED_BINARIES to run prebuilt binaries with the test pipeline.
In some cases, it may be desirable to prebuild binaries and run all tests,
for example to run benchmarks with various experiments. Allow the top-level
Makefile to support this by checking for a STAGED_BINARIES variable.

PiperOrigin-RevId: 410673120
2021-11-17 17:49:35 -08:00
Jamie LiuandgVisor bot f53b8a38e5 Add go:build directives as required by Go 1.17's gofmt.
PiperOrigin-RevId: 385894869
2021-07-20 16:28:45 -07:00
Fabricio VoznikaandgVisor bot 07972dd054 Fix test_app task-tree
Executing `select {}` to wait forever triggers Go runtime deadlock
detection and kills the child, causing the number actual processes
be less than expected.

PiperOrigin-RevId: 376298799
2021-05-27 19:55:03 -07:00
Ayush RanjanandgVisor bot 1eb8c7521e [perf] Fix profiling in benchmarking jobs.
Due to https://github.com/moby/moby/issues/42345, the docker daemon is passing
the incorrect `--root` flag to runsc. So our profiler is not able to find the
container stat files where it expects them to be.

PiperOrigin-RevId: 372067954
2021-05-05 00:02:37 -07:00
Adin ScannellandgVisor bot 7e1a134e67 Clean test tags.
PiperOrigin-RevId: 369505182
2021-04-20 13:11:25 -07:00
Fabricio VoznikaandgVisor bot f18c75f691 Fail tests when container returns non-zero status
PiperOrigin-RevId: 366839955
2021-04-05 11:39:53 -07:00
Zeling FengandgVisor bot 670f17a3e5 Fix logs for packetimpact tests cleanup
- Don't cleanup containers in Network.Cleanup, otherwise containers will
  be killed and removed several times.
- Don't set AutoRemove for containers. This will prevent the confusing
  'removal already in progress' messages.

Fixes #3795

PiperOrigin-RevId: 364404414
2021-03-22 14:10:00 -07:00
Ayush RanjanandgVisor bot c3ff9f93bc [op] Replace syscall package usage with golang.org/x/sys/unix in pkg/.
The syscall package has been deprecated in favor of golang.org/x/sys.

Note that syscall is still used in the following places:
- pkg/sentry/socket/hostinet/stack.go: some netlink related functionalities
  are not yet available in golang.org/x/sys.
- syscall.Stat_t is still used in some places because os.FileInfo.Sys() still
  returns it and not unix.Stat_t.

Updates #214

PiperOrigin-RevId: 360701387
2021-03-03 10:25:58 -08:00
Zach KoopmansandgVisor bot d7c80588da Fix bug with iperf and don't profile runc.
Fix issue with iperf where b.N wasn't changing across runs.
Also, if the given runtime is runc/not given, don't run a profile against it.

PiperOrigin-RevId: 357231450
2021-02-12 11:28:16 -08:00
Dean DengandgVisor bot ca201a0360 Switch uses of os.Getenv that check for empty string to os.LookupEnv.
Whether the variable was found is already returned by syscall.Getenv.
os.Getenv drops this value while os.Lookupenv passes it along.

PiperOrigin-RevId: 351674032
2021-01-13 15:15:20 -08:00
Etienne PerotandgVisor bot 9da3749fec testutil: Create a multiLogger that logs to multiple Loggers.
This is useful when using the shell library in order to log to both the test
log and the standard logs.

PiperOrigin-RevId: 351673465
2021-01-13 15:09:50 -08:00
Fabricio VoznikaandgVisor bot 29ebab9ef0 Delete shim v1
gvisor-containerd-shim is not compatible with containerd 1.1 or earlier.
Starting from containerd 1.2, shim v2 is the preferred interface.

PiperOrigin-RevId: 351485556
2021-01-12 17:54:10 -08:00
Etienne PerotandgVisor bot 666c5c71d4 Create console test library.
This creates a TTY pair and runs `/bin/sh` in interactive mode within it.
It provides useful helper functions to interact with the shell and read the
output of commands run within it.

This is meant to be used for testing upcoming changes allowing `runsc exec` to
work in `-detach=false -tty=true` mode.

PiperOrigin-RevId: 350841006
2021-01-08 14:51:50 -08:00
Adin ScannellandgVisor bot f5764a605a Add benchmarks targets to BuildKite.
This includes minor fix-ups:

* Handle SIGTERM in runsc debug, to exit gracefully.
* Fix cmd.debug.go opening all profiles as RDONLY.
* Fix the test name in fio_test.go, and encode the block size in the test.

PiperOrigin-RevId: 350205718
2021-01-05 13:21:54 -08:00
Adin ScannellandgVisor bot caec235b70 Simplify profiling and benchmarks.
- Tweak the benchmarks to work with b.N where appropriate. In many cases,
  b.N was simply being ignored. This creates an implicit dependency in the
  user passing a reasonable benchtime (less than or equal to the actual
  runtime of the test, or using the X syntax) otherwise the test runs
  forever.
- In cases where the above is impossible, explicitly set benchtime from
  the test wrapper, to prevent the above behavior (tensorflow).
- Drop the *Reverse variants, which are simply hey benchmarks. We should
  just add a hey benchmark. The platforms benchmarks already include a
  native platform, and thus these benchmarks are incredibly confusing.
  (In other words, BenchmarkNginxReverse has nothing to do with an nginx
  benchmark for runsc.)
- Remove the redunant Harness object, which contains no state, in order
  to slightly simplify the code.
- Make Block and Heap profiling actually work, but setting appropriate
  runtime parameters (and plumbing them through the config).
- Split the profiling into two phases: start and stop, since some will
  need to be started early, and others will need to happen at the end.

PiperOrigin-RevId: 349495377
2020-12-29 18:29:12 -08:00
Peter JohnstonandgVisor bot c3b5ce0336 Support icmpv6 transport protocol
PiperOrigin-RevId: 346101076
2020-12-07 08:44:44 -08:00
Adin ScannellandgVisor bot 0d1d872f7f Support partitions for other tests.
PiperOrigin-RevId: 345399936
2020-12-03 01:00:21 -08:00
Zeling FengandgVisor bot 048797160b Make testutil.RandomID safe for concurrent uses
testutil.RandomID was using Rand.Read which is not safe for concurrent use.
It caused name conflicts in packetimpact tests when they are run in parallel.
Adding a mutex to protect the Rand.Read operation.

PiperOrigin-RevId: 345360062
2020-12-02 19:14:51 -08:00
Zeling FengandgVisor bot c0897a4b49 Do not start a ContainerExec twice
ContainerExecStart and ContainerExecAttach both call the /exec/id/start API
endpoint.

PiperOrigin-RevId: 344946627
2020-11-30 21:22:55 -08:00
Adin ScannellandgVisor bot 3dc6b1b1c2 Ensure containerd is used from installed location.
Currently, if containerd is installed locally via tools/installers/containerd,
then it will not necessarily be used if containerd is installed in the system
path. This means that the existing containerd tests are all likely broken.

Also, use libbtrfs-dev instead of btrfs-tools, which is not actually required.

PiperOrigin-RevId: 344879109
2020-11-30 13:40:23 -08:00
Adin ScannellandgVisor bot cd577716bf Fail gracefully if Docker is not configured with ipv6.
PiperOrigin-RevId: 343927315
2020-11-23 14:24:27 -08:00
Fabricio VoznikaandgVisor bot 3ac4ff4c56 Add support for TTY in multi-container
Fixes #2714

PiperOrigin-RevId: 342950412
2020-11-17 14:51:24 -08:00
Fabricio VoznikaandgVisor bot c8704e4bdf Enable more VFS2 tests
Updates #1487

PiperOrigin-RevId: 335516732
2020-10-05 15:54:36 -07:00
Ayush RanjanandgVisor bot c011d4da7d [testing] Use container address to talk to server running inside container.
Docker does not have IPv6 port forwarding as tracked by the following issue:
https://github.com/moby/moby/issues/11518

So when running bazel itself inside a docker container, we can not use the host
port bindings to communicate with sockets inside the container. This was causing
integration tests and image tests to fail when run through our Makefile targets.

PiperOrigin-RevId: 332355051
2020-09-17 17:58:08 -07:00
Zeling FengandgVisor bot f7a4ef7453 Add support to run packetimpact tests against Fuchsia
blaze test <test_name>_fuchsia_test will run the corresponding packetimpact
test against fuchsia.

PiperOrigin-RevId: 329835290
2020-09-02 19:19:40 -07:00
Fabricio VoznikaandgVisor bot 9f715d4742 Make flag propagation automatic
Use reflection and tags to provide automatic conversion from
Config to flags. This makes adding new flags less error-prone,
skips flags using default values (easier to read), and makes
tests correctly use default flag values for test Configs.

Updates #3494

PiperOrigin-RevId: 328662070
2020-08-26 20:24:41 -07:00