Commit Graph
145 Commits
Author SHA1 Message Date
Nicolas LacasseandgVisor bot 5530811417 Tweaks to containerd tests and helpers.
PiperOrigin-RevId: 565839195
2023-09-15 20:02:41 -07:00
Andrei Vagin 51fa9984e7 Update bazel, rules_go and gazelle 2023-08-03 18:22:26 -07:00
Ian LewisandgVisor bot 40d6c048af Update host redirect handling for gvisor.dev
We now make sure that the requested domain is a valid domain based on the
custom domain and project ID settings before redirecting.

PiperOrigin-RevId: 548859553
2023-07-17 19:03:44 -07:00
Andrei VaginandgVisor bot 6e2d334d8f buildkite: run runtime tests on systrap
PiperOrigin-RevId: 533464677
2023-05-19 08:48:15 -07:00
Ayush RanjanandgVisor bot 520c961859 Print $RUNTIME_ARGS when configuring runsc runtime.
Helps with seeing what is actually being installed.

PiperOrigin-RevId: 526727666
2023-04-24 12:49:56 -07:00
Zach KoopmansandgVisor bot 822ae5ac8c Fix flakes in portforward test.
Attempt to fix flaky port forward test using "netstat" in the container
to check the a process is listening on the port before attempting to
connect.

Also, re-enable the test in a seperate job, but w/ a soft fail. This
will be removed later in favor of adding port-forward to integration
tests to remove the high overhead of starting a new job (scheduling,
compiling runsc, downloading images, etc).

PiperOrigin-RevId: 526135859
2023-04-21 14:28:31 -07:00
gVisor bot d034171d9c Merge pull request #8679 from avagin:cpp-warnings
PiperOrigin-RevId: 523157922
2023-04-10 10:59:51 -07:00
Zach KoopmansandgVisor bot 139bb8ab5d Add portforward stream mode.
Port forward stream mode will be used for k8s. Stream mode takes a
UNIX socket and donates a connected FD to the sandbox in question,
and returns. No proxy process is kept around to do the transfer
and the UDS will be returned to containerd as the address on which
to send i/o to the forwarded port.

PiperOrigin-RevId: 521823250
2023-04-04 11:46: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
Andrei Vagin 3445db339d Fix all c++ compile time warnings 2023-03-09 19:01:00 -08: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 00cc9dcb0a Remove //tools/nogo:full flag.
With the latest nogo change, facts are no longer in the build paths. Since full
is only used to speed these paths (and is enabled for full analysis) the full
flag is now redundant and can be removed safely.

PiperOrigin-RevId: 511935530
2023-02-23 18:08:37 -08:00
4acf987b22 Run tools/install_containerd.sh without sudo -H.
This script was being run as root. This script clones containerd and builds it.
On some Ubuntu versions, sudo(1) does not change the home directory. On
oldkernel machines from BuildKite, this script was running with
$HOME=/home/agent. As a result, root was writing and creating files in
/home/agent/.cache/go-build/. Other tests that call `go build` that were
scheduled to run on such VMs would fail due to permission issues because
/home/agent/.cache/go-build/ is owned by root.

Run the tools/install_containerd.sh script sudo -H so that the home directory
is set appropriately and all packages are built and installed with root user's
cache in /root/.cache/.

Also fixed lint errors in tools/install_containerd.sh and got rid of redundant
sudo calls. Added the check that the script must be run as root.

Co-authored-by: Andrei Vagin <[email protected]>
Acknowledgements: Andrei Vagin discovered this issue.
PiperOrigin-RevId: 511661564
2023-02-22 19:43:15 -08:00
Andrei VaginandgVisor bot a12c3a3f23 Open-sourcing the systrap platform.
The systrap platform like the ptrace platform uses stub processes to manage
the user address space. The difference is how they intercept system calls and
other events like memory faults, exceptions, etc.

In case of systrap, all events that have to be handled by the Sentry trigger
signals that are handled by a custom signal handler installed on stub
processes. The signal handler switches control to the Sentry.

Here are a few other optimizations:
* On x86, system calls can be replaced with a function call to remove overhead
  of signals.
* For fast interactions of sentry and stub processes, futex wait/wake can
  be a bottle neck, so we use a polling mode.

The platform is launched for the purpose of testing and gathering initial
feedback. It is not yet ready for use in production.

PiperOrigin-RevId: 511650064
2023-02-22 18:22:49 -08:00
Andrei Vagin 3217061ac5 Bump go version to 1.20
Signed-off-by: Andrei Vagin <[email protected]>
2023-02-10 08:32:17 -08:00
Ayush RanjanandgVisor bot 6b0f87b532 Add self medium to overlay2.
This medium instructs runsc to place the overlay-backing host file inside the
mount being overlayed itself. The file is placed inside the root directory of
the mount at path `.gvisor.overlay.img.{CID}/filestore-{random}`.

Note that the same volume may be mounted at various places in the same
container. Furthermore, the same volume may be mounted by multiple containers
in the same pod. So we create a filestore directory in the mount which is
unique to each container. This filestore directory hosts all the filestore
files for the mount for the given container. This directory is destroyed along
with the contianer on `runsc delete`.

The self medium based host file is a named file because it needs to be
discoverable via path traversal from the host. For the root mount, this allows
k8s to scan the container's root filesystem and apply local ephemeral storage
limits appropriately. This makes self medium appropriate for k8s usage.

Note that the overlay host file (MemoryFile) is a sparse file. Thankfully k8s
uses stat.st_blocks to perform accounting, not stat.st_size. stat.st_blocks
indicates the number of pages allocated towards a file, which works well with
sparse files.

PiperOrigin-RevId: 507301254
2023-02-05 11:08:47 -08:00
Ayush RanjanandgVisor bot 2fd3cbe22c Create separate overlay filestore files for each overlay mount.
1e2bc64038 ("Create separate overlay filestore for subcontainers.") moved
the ownership of pgalloc.MemoryFile to tmpfs mount (upper layer in overlay).
However, this also means that each tmpfs mount needs its own filestore file.
Currently if there are multiple overlay mounts in a container that are backed
by the same host file. Since they use different MemoryFiles, they will
overwrite each other.

This change creates a separate overlay file per overlay mount per container
and plumbs the FDs to their respective tmpfs mounts. This is similar to how
gofer FDs are dealt with. Added a regression test for this too.

PiperOrigin-RevId: 507289704
2023-02-05 09:11:45 -08:00
Lucas ManningandgVisor bot 68ecfd8c81 Delete old FUSE tests.
These are made obsolete by the new add_fusefs attribute. There is
no reason to keep them around, they were already disabled.

PiperOrigin-RevId: 506440841
2023-02-01 15:36:39 -08:00
Ayush RanjanandgVisor bot 710955192d Add dir= prefix in overlay2 flag's medium.
This is to make it clear that the host file will be created inside this
directory. This also makes it look cleaner when other medium options are added
later.

PiperOrigin-RevId: 505033408
2023-01-26 22:56:52 -08:00
Ayush RanjanandgVisor bot 8431399462 Add ENAMETOOLONG checks in overlayfs.
Linux overlayfs uses the max of all layers' filename length limit. Do the same
in gVisor.

This is needed to get PHP runtime test ext/standard/tests/strings/007.phpt to
pass with overlayfs.

PiperOrigin-RevId: 493942515
2022-12-08 11:04:37 -08:00
Lucas ManningandgVisor bot 9343d1484d Remove FUSE feature flag and enable by default.
PiperOrigin-RevId: 493410677
2022-12-06 14:22:34 -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
Ayush RanjanandgVisor bot 0c516fed5c Add docker test for external UDS connect.
Serves as a regression test for #8126.
Our unit tests didn't catch the issue because they run runsc with the flag
-TESTONLY-unsafe-nonroot. Docker tests are more e2e, they run tests in Docker
containers.

Fixes #8126

PiperOrigin-RevId: 488945922
2022-11-16 08:26:21 -08:00
Etienne PerotandgVisor bot f7a003773f Label all benchmarks with tag gvisor_benchmark.
This makes it easy to list all the available benchmark targets with `bazel`.

PiperOrigin-RevId: 486212679
2022-11-04 13:10:21 -07: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
Ayush RanjanandgVisor bot 0abea14601 Update containerd tests to use versions 1.5.11 and 1.6.2.
These versions are compatible with Go 1.18. There are a lot of OSS bugs
about this issue. Notable discussions:
- golang/go#51285
- containerd/containerd#6586

This was fixed upstream in the main branch in containerd/containerd#6605.
The fix was back-ported to v1.5 and v1.6 in containerd/containerd#6716
and containerd/containerd#6717 respectively.

These backports are available in the following versions:
```shell
/tmp/gopathJJGZf/containerd$ git tag --contains 765df66099eec88d0365eaa1e9a933877a058f0b
v1.6.2
v1.6.3
v1.6.4
v1.6.5
v1.6.6
v1.6.7
v1.6.8
/tmp/gopathJJGZf/containerd$ git tag --contains 86bec213720b54bf9ea2813e2c2a577271af58d3
v1.5.11
v1.5.12
v1.5.13
```

So use the smallest versions out of them.

PiperOrigin-RevId: 480965567
2022-10-13 13:10:59 -07:00
Ayush RanjanandgVisor bot 5d71ecdddf Enable lisafs by default for runsc.
Made some other changes:
- We no longer generate a separate runtime for p9 on `make
  dev`.
- We no longer run p9 runtime tests. Instead run lisafs runtime
  tests on presubmits.
- All tests are generated with lisafs. Only 1 p9 variant is
  generated with default platform.
- Run integration tests only with lisafs.

P9 is now considered deprecated.

Use `--lisafs=false` if you need to disable it. Make sure to
report a bug if you have the need to disable LISAFS.

Fixes #6319

PiperOrigin-RevId: 469548694
2022-08-23 13:58:27 -07:00
Etienne PerotandgVisor bot dfa3e17977 Makefile: Add option to not benchmark runc.
This is useful when wanting to run benchmarks in a way where the output can
be captured to a file, such that this file only contains one platform's
specific performance data.

PiperOrigin-RevId: 468061772
2022-08-16 17:06:01 -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
Etienne PerotandgVisor bot 5d4ed0a364 Makefile: Don't overwrite RUNTIME-related variables if they are already set.
Without this, setting `RUNTIME` in the environment has no effect.

PiperOrigin-RevId: 459311928
2022-07-06 12:15:06 -07:00
Kevin KrakauerandgVisor bot 3936740eb5 make gofer directory cache size configurable
Passing --dcache=N causes all gofer mounts to use a global dirent cache of size
N.

PiperOrigin-RevId: 457867503
2022-06-28 18:58:28 -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 60f87e3f4a Make root_test and containerd tests work on BuildKite on COS.
When running in COS in a container, things are different when accessing
process or cgroup data.

This CL uses the `HOST_PROCFS_MOUNTPOINT` and `HOST_CGROUPFS_MOUNTPOINT`
environment variables as alternate roots for `/proc` and `/sys/fs/cgroup` in
`root_test` and in other related places.

Also includes some minor refactors:

- Factor out code to get the parent PID of a child PID to its own function
- Fix some typos

PiperOrigin-RevId: 457102457
2022-06-24 15:12:55 -07:00
Etienne PerotandgVisor bot f8f1917207 Makefile: Set RUNTIME_DIR actually work the way it is documented.
Prior to this, setting `RUNTIME_DIR` had no effect, as the Makefile always
clobbered it.

PiperOrigin-RevId: 456893921
2022-06-23 17:14:38 -07:00
Etienne PerotandgVisor bot 15a3941013 Makefile: Add a configuration variable to restrict benchmarks by platform.
PiperOrigin-RevId: 456890256
2022-06-23 16:53:53 -07:00
Etienne PerotandgVisor bot 1d1fc5e065 BuildKite pre-command: Use alternate way to reload Docker when available.
PiperOrigin-RevId: 456884864
2022-06-23 16:24:17 -07:00
Fabricio VoznikaandgVisor bot 6f66cab592 Trace points integration test
Updates #4805

PiperOrigin-RevId: 451007875
2022-05-25 14:00:39 -07:00
Andrei VaginandgVisor bot 010befecea buildkite: allow to run containerd tests on arm64
k8s.gcr.io/busybox:latest doesn't have the arm variant, so
let's use the upstream busybox and create /etc/recolv.conf symlink.

PiperOrigin-RevId: 450059917
2022-05-20 14:11:04 -07:00
Zach KoopmansandgVisor bot c70afab9f6 [benchmarks] Add profiles back to buildkite.
PiperOrigin-RevId: 441223389
2022-04-12 10:19:26 -07:00
Andrei VaginandgVisor bot c4de1b7bfa make: set --//tools/nogo:fast by default
nogo:fast is converted to nogo:full with the opposite meaning.
All nogo tests have to be always executed with this option.

Analyzing Go Standard Library takes about 10 minutes on buildkite,
but it is required only to run nogo tests.

PiperOrigin-RevId: 438343203
2022-03-30 10:53:28 -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
Zach KoopmansandgVisor bot 9917872ab4 [benchmarks] Fix issue with run-benchmark.
make run-benchmark should not install a new runtime. Instead, just run the
benchmark with the given RUNTIME.

Move all of the logic to install the runtime to benchmark-platforms.

PiperOrigin-RevId: 434838884
2022-03-15 13:22:07 -07:00
Ayush RanjanandgVisor bot 042dac5db2 Enable all tests for lisafs.
- Generates a lisafs variant of all syscall tests.
- Adds Makefile targets to run runtime tests with lisafs. We run runtime tests
  continuously (on every commit to master) and on presubmits iff the commit
  message contains "lisafs".
- Updates the docker tests target to run the integration tests with lisafs too.

Fixes #5466

PiperOrigin-RevId: 433782954
2022-03-10 10:09:05 -08:00
Ayush RanjanandgVisor bot dece8fc334 Make watchdog panic for runtime tests.
This will make deadlocks more apparent in test results. Currently runtime tests
just timeout after 30 mins if there is some deadlock.

PiperOrigin-RevId: 433654750
2022-03-09 21:46:37 -08:00
Adin ScannellandgVisor bot 2558b76088 Make release pipeline architecture-independent.
PiperOrigin-RevId: 432006218
2022-03-02 12:51:03 -08:00
Fabricio VoznikaandgVisor bot afaa4eeeb6 Drop support for containerd 1.3
Update containerd versions used in test to the latest of each
minor version.

PiperOrigin-RevId: 431993047
2022-03-02 11:55:29 -08: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