Commit Graph
57 Commits
Author SHA1 Message Date
Lucas ManningandgVisor bot 621c632afc A few fixes to run tests on 6.2+ kernels
* disable broken socket_inet_loopback test // Lucas Manning
* disable lseek tests on anon inodes. They have been broken by
commit e7478158e1378325907edfdd960eca98a1be405b
Date:   Wed Jun 29 15:06:57 2022 +0200
    fs: clear or set FMODE_LSEEK based on llseek function

* don't check memory.kmem.limit_in_bytes, it has been deprecated and dropped:
commit 86327e8eb94c52eca4f93cfece2e29d1bf52acbf
Date:   Tue Jul 4 13:52:40 2023 +0200
    memcg: drop kmem.limit_in_bytes
commit 58056f77502f3567b760c9a8fc8d2e9081515b2d
Date:   Fri Nov 5 13:37:44 2021 -0700
    memcg, kmem: further deprecate kmem.limit_in_bytes
commit 0158115f702b0ba208ab0b5adf44cae99b3ebcc7
Date:   Mon Sep 23 15:37:22 2019 -0700
    memcg, kmem: deprecate kmem.limit_in_bytes
PiperOrigin-RevId: 562915457
2023-09-05 15:51:21 -07:00
Ayush RanjanandgVisor bot 03ab255e51 Preserve sandbox process env vars only for --TESTONLY-unsafe-nonroot.
Earlier setCapsAndCallSelf() and callSelfAsNobody() were unconditionally
clearing the sandbox process's env vars. But in some cases we want to preserve
it. For example, when running runsc-race, we want to set GLIBC_TUNABLES for the
sandbox process. Note that runsc-race requires --TESTONLY-unsafe-nonroot=true.

Right now, when --TESTONLY-unsafe-nonroot is set, boot process does not end up
calling setCapsAndCallSelf() or callSelfAsNobody(). So the env vars are
retained as desired. But with directfs, those methods are called in spite of
--TESTONLY-unsafe-nonroot. So this change is required to preserve env vars with
--directfs && --TESTONLY-unsafe-nonroot.

This change also adds a test to verify that the sandbox process is running with
no leaked environment variables.

PiperOrigin-RevId: 533170470
2023-05-18 10:24:09 -07:00
Zach KoopmansandgVisor bot 41975e109f Enable portforward test after fix.
PiperOrigin-RevId: 526688386
2023-04-24 10:42:03 -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
Ayush RanjanandgVisor bot 835c8c8cf5 Skip TestPortForwardLocalMode.
This test is blocking submits.

PiperOrigin-RevId: 523497354
2023-04-11 14:03:32 -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
Adin ScannellandgVisor bot 2911d8c3b8 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -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
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
Lucas ManningandgVisor bot 3626d4cc86 Ignore systemd "scope already exists" errors.
This copies the behavior of runc. See  https://github.com/opencontainers/runc/blob/4a51b047036cf16d4f124548c2a7ff24b5640bad/libcontainer/cgroups/systemd/common.go#L150

PiperOrigin-RevId: 471110557
2022-08-30 15:53:26 -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
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
Ayush RanjanandgVisor bot 2026e1f078 Reformat codebase.
PiperOrigin-RevId: 449358041
2022-05-17 17:48:35 -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 12b242f4d2 Automated rollback of changelist 431455723
PiperOrigin-RevId: 431504004
2022-02-28 12:53:28 -08:00
Zach KoopmansandgVisor bot 50592e862d Fix issue with parsing flags in root_test.
PiperOrigin-RevId: 431455723
2022-02-28 09:42:39 -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
Andrei Vagin 057c5f55a8 runsc: Fix the data race
==================
WARNING: DATA RACE
Write at 0x00c000115be0 by main goroutine:
  gvisor.dev/gvisor/runsc/sandbox.(*Sandbox).waitForStopped()
      runsc/sandbox/sandbox.go:1275 +0x24b
  gvisor.dev/gvisor/runsc/sandbox.(*Sandbox).Wait()
      runsc/sandbox/sandbox.go:823 +0xa2c
  gvisor.dev/gvisor/runsc/container.(*Container).Wait()
      runsc/container/container.go:524 +0x131
  gvisor.dev/gvisor/runsc/cmd.startContainerAndWait()
      runsc/cmd/do.go:398 +0xa18
  gvisor.dev/gvisor/runsc/cmd.(*Do).Execute()
      runsc/cmd/do.go:156 +0xc16
  github.com/google/subcommands.(*Commander).Execute()
      external/com_github_google_subcommands/subcommands.go:200 +0x66b
  github.com/google/subcommands.Execute()
      external/com_github_google_subcommands/subcommands.go:481 +0x2096
  gvisor.dev/gvisor/runsc/cli.Main()
      runsc/cli/main.go:243 +0x1fb4
  main.main()
      runsc/main.go:23 +0x56

Previous read at 0x00c000115be0 by goroutine 9:
  gvisor.dev/gvisor/runsc/sandbox.(*Sandbox).connError()
      runsc/sandbox/sandbox.go:387 +0x1e9
  gvisor.dev/gvisor/runsc/sandbox.(*Sandbox).sandboxConnect()
      runsc/sandbox/sandbox.go:381 +0x291
  gvisor.dev/gvisor/runsc/sandbox.(*Sandbox).SignalProcess()
      runsc/sandbox/sandbox.go:932 +0x135
  gvisor.dev/gvisor/runsc/container.(*Container).ForwardSignals.func1()
      runsc/container/container.go:591 +0x267
  gvisor.dev/gvisor/pkg/sentry/sighandling.handleSignals()
      pkg/sentry/sighandling/sighandling.go:63 +0x4f8

Goroutine 9 (running) created at:
  gvisor.dev/gvisor/pkg/sentry/sighandling.StartSignalForwarding()
      pkg/sentry/sighandling/sighandling.go:96 +0x284
  gvisor.dev/gvisor/runsc/container.(*Container).ForwardSignals()
      runsc/container/container.go:589 +0x21d
  gvisor.dev/gvisor/runsc/cmd.startContainerAndWait()
      runsc/cmd/do.go:395 +0x9d0
  gvisor.dev/gvisor/runsc/cmd.(*Do).Execute()
      runsc/cmd/do.go:156 +0xc16
  github.com/google/subcommands.(*Commander).Execute()
      external/com_github_google_subcommands/subcommands.go:200 +0x66b
  github.com/google/subcommands.Execute()
      external/com_github_google_subcommands/subcommands.go:481 +0x2096
  gvisor.dev/gvisor/runsc/cli.Main()
      runsc/cli/main.go:243 +0x1fb4
  main.main()
      runsc/main.go:23 +0x56
==================
Found 1 data race(s)

Signed-off-by: Andrei Vagin <[email protected]>
2021-12-23 13:03:58 -08:00
gVisor bot 17b42b3cbf Merge pull request #6821 from dqminh:feature/cgroupv2
PiperOrigin-RevId: 413032543
2021-11-29 18:37:42 -08:00
Daniel Dao 79b4b50ad5 runsc: Add cgroup v2 implementation
Adds support for cgroupv2 based on the common cgroup interface.

The cgroupv2 implementation mostly mirrors the structure of cgroupv1,
with many helper functions derived from containerd/cgroups and opencontainers/runc
implementations.  We implemented the following controllers: cpu, cpuset, memory,
io, pids, hugetlb.

In order to avoid upgrading containerd dependency (to get oom poller
implementation), we copied the oom poller implementation for cgroupv2
into shim/oom_v2.go. This requires containerd/cgroups dependency to have
cgroupv2 support which we already have.

Signed-off-by: Daniel Dao <[email protected]>
2021-11-26 10:14:08 +00:00
Fabricio VoznikaandgVisor bot 1cfca31c2b Add support for containerd 1.5
"cri.runtimeoptions.v1" moved to "runtimeoptions.v1" and containerd
configuration format version 2 is required.

Updates #6449

PiperOrigin-RevId: 405474653
2021-10-25 13:17:25 -07:00
gVisor bot 1b0f90378b Merge pull request #6292 from btw616:local-timezone
PiperOrigin-RevId: 386988406
2021-07-26 16:47:13 -07:00
Fabricio VoznikaandgVisor bot 1ee531cff9 Fixes to runsc cgroups
When loading cgroups for another process, `/proc/self` was used in
a few places, causing the end state to be a mix of the process
and self. This is now fixes to always use the proper `/proc/[pid]`
path.

Added net_prio and net_cls to the list of optional controllers. This
is to allow runsc to execute then these cgroups are disabled as long
as there are no net_prio and net_cls limits that need to be applied.

Deflake TestMultiContainerEvent.

Closes #5875
Closes #5887

PiperOrigin-RevId: 372242687
2021-05-05 17:39:29 -07: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
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
Adin ScannellandgVisor bot 0dab30d83f Fix simple mistakes identified by goreportcard.
These are primarily simplification and lint mistakes. However, minor
fixes are also included and tests added where appropriate.

PiperOrigin-RevId: 351425971
2021-01-12 12:38:22 -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 ScannellandShentubot 0bcbf188c6 Refactor the Makefile to avoid recursive Make.
Recursive make is difficult to follow and debug. Drop this by using
internal functions, which, while difficult, are easier than trying to
following recursive invokations.

Further simplify the Makefile by collapsing the image bits and removing
the tools/vm directory, which is effectively unused.

Fixes #4952

PiperOrigin-RevId: 346569133
2020-12-09 15:53:23 -08:00
Etienne PerotandgVisor bot 8d8d0dcf1b Typo fix.
PiperOrigin-RevId: 345062676
2020-12-01 11:31:25 -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 8711471e1f Fix failure setting OOM score adjustment
When OOM score adjustment needs to be set, all the containers need to be
loaded to find all containers that belong to the sandbox. However, each
load signals the container to ensure it is still alive. OOM score
adjustment is set during creation and deletion of every container, generating
a flood of signals to all containers. The fix removes the signal check
when it's not needed.

There is also a race fetching OOM score adjustment value from the parent when
the sandbox exits at the same  time (the time it took to signal containers above
made this window quite large). The fix is to store the original value
in the sandbox state file and use it when the value needs to be restored.

Also add more logging and made the existing ones more consistent to help with
debugging.

PiperOrigin-RevId: 340940799
2020-11-05 15:36:20 -08:00
Ayush RanjanandgVisor bot e68f8eb698 Remove unused scripts.
PiperOrigin-RevId: 333408633
2020-09-23 17:38:02 -07:00
Adin ScannellandgVisor bot e6393a0700 Add nogo support to go_binary and go_test targets.
Updates #3374

PiperOrigin-RevId: 328378700
2020-08-25 12:18:25 -07:00
Adin ScannellandgVisor bot 8263dbfb0f Add standard entrypoints for test targets.
PiperOrigin-RevId: 322265513
2020-07-20 18:05:05 -07:00
gVisor bot 517ba1fffe Merge pull request #2672 from amscanne:shim-integrated
PiperOrigin-RevId: 321053634
2020-07-13 16:10:58 -07:00
Adin Scannell 8c1e2ee569 Update shim to build using bazel.
The go.mod dependency tree for the shim was somehow contradictory. After
resolving these issues (e.g. explicitly imported k8s 1.14, pulling a
specific dbus version), and adding all dependencies, the shim can now be
build as part of the regular bazel tree.

As part of this process, minor cleanup was done in all the source files:
headers were standardized (and include "The gVisor Authors" in addition
to the "The containerd Authors" if originally derived from containerd
sources), and comments were cleaned up to meet coding standards.

This change makes the containerd installation dynamic, so that multiple
versions can be tested, and drops the static installer for the VM image
itself.

This change also updates test/root/crictl_test.go and related utilities,
so that the containerd tests can be run on any version (and in cases
where it applies, they can be run on both v1 and v2 as parameterized
tests).
2020-07-09 17:39:47 -07:00
Zach KoopmansandgVisor bot c5a0007cec Move all tests to new docker API.
Moves following to new dockerutil API:
- //test/e2e:integration_test
- //test/image:image_test
- //test/iptables:iptables_test
- //test/root:root_test
- //test/packetimpact:packetimpact_test

PiperOrigin-RevId: 320253118
2020-07-08 13:26:23 -07:00
Ian LewisandgVisor bot 95c3961bbb Set the HOME environment variable for sub-containers.
Fixes #701

PiperOrigin-RevId: 316025635
2020-06-11 19:31:24 -07:00
Fabricio VoznikaandgVisor bot 279ce40443 Move Cleanup to its own package
PiperOrigin-RevId: 313663382
2020-05-28 14:49:06 -07:00
Fabricio VoznikaandgVisor bot 55f009fde3 Propagate PID limit from OCI to sandbox cgroup
Closes #2489

PiperOrigin-RevId: 308362434
2020-04-24 18:17:01 -07:00
Adin ScannellandgVisor bot e4cf551982 Standardize all Docker images.
This change moves all Docker images to a standard location, and abstracts the
build process so that they can be maintained in an automated fashion. This also
allows the images to be architecture-independent.

All images will now be referred to by the test framework via the canonical
`gvisor.dev/images/<name>`, where `<name>` is a function of the path within the
source tree.

In a subsequent change, continuous integration will be added so that the images
will always be correct and available locally.

In the end, using `bazel` for Docker containers is simply not possible. Given
that we already have the need to use `make` with the base container (for
Docker), we extend this approach to get more flexibility.

This change also adds a self-documenting and powerful Makefile that is intended
to replace the collection of scripts in scripts. Canonical (self-documenting)
targets can be added here for targets that understand which images need to be
loaded and/or built.

PiperOrigin-RevId: 308322438
2020-04-24 14:11:42 -07:00
Adin ScannellandgVisor bot 1b8133d9f9 Simplify Docker test infrastructure.
This change adds a layer of abstraction around the internal Docker APIs,
and eliminates all direct dependencies on Dockerfiles in the infrastructure.

A subsequent change will automated the generation of local images (with
efficient caching). Note that this change drops the use of bazel container
rules, as that experiment does not seem to be viable.

PiperOrigin-RevId: 308095430
2020-04-23 11:33:30 -07:00
Adin ScannellandgVisor bot c5f08fe7fc Add a functional vm_test for root_test.
This change renames the tools/images directory to tools/vm for clarity, and
adds a functional vm_test. Sharding is also added to the same test, and some
documentation added around key flags & variables to describe how they work.

Subsequent changes will add vm_tests for other cases, such as the runtime tests.

PiperOrigin-RevId: 307492245
2020-04-20 15:48:27 -07:00
Fabricio VoznikaandgVisor bot 48cf365ad6 Add test name to boot and gofer log files
This is to make easier to find corresponding logs in
case test fails.

PiperOrigin-RevId: 307104283
2020-04-17 13:28:54 -07:00
Adin Scannell e6ee1a2b1b Fix all printf formatting errors.
Updates #2243
2020-04-08 10:14:34 -07:00
Fabricio VoznikaandgVisor bot 97c787994c Skip process if it has exited
PiperOrigin-RevId: 300802159
2020-03-13 12:11:13 -07:00
Fabricio VoznikaandgVisor bot aaf14f82d5 Kill sandbox process when parent process terminates
When the sandbox runs in attached more, e.g. runsc do, runsc run, the
sandbox lifetime is controlled by the parent process. This wasn't working
in all cases because PR_GET_PDEATHSIG doesn't propagate through execve
when the process changes uid/gid. So it was getting dropped when the
sandbox execve's to change to user nobody.

PiperOrigin-RevId: 300601247
2020-03-12 12:32:26 -07:00
Adin ScannellandgVisor bot fe55dafa15 Update visibility.
PiperOrigin-RevId: 294265019
2020-02-10 11:30:21 -08:00
Adin ScannellandgVisor bot 5cd5c2536a Standardize on tools directory.
PiperOrigin-RevId: 291745021
2020-01-27 12:21:00 -08:00