Commit Graph

5013 Commits

Author SHA1 Message Date
Aleksa Sarai 4b98e4a73a MAINTAINERS: update Aleksa's email
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-03-04 10:38:35 +11:00
Kir Kolyshkin 1820c42547 Merge pull request #2768 from kolyshkin/unit-386
ci/gha: add i386 unit test
2021-02-25 18:23:36 -08:00
Akihiro Suda d56a9c67ac Merge pull request #2812 from kolyshkin/memory-tight 2021-02-26 10:52:17 +09:00
Akihiro Suda 8bddca5118 Merge pull request #2819 from Iceber/fix-comment
libcontainer: fix LinuxFactory comments
2021-02-25 18:08:04 +09:00
Mrunal Patel d11985a586 Merge pull request #2799 from kolyshkin/race1
Fix data races, enable testing with -race
2021-02-24 16:37:34 -08:00
Iceber Gu 916654fffa libcontainer: fix LinuxFactory comments
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-02-24 15:51:06 +08:00
Aleksa Sarai c153261830 merge branch 'pr-2786'
Daniel Dao (1):
  Do not convert blkio weight value using blkio->io conversion scheme

LGTMs: @kolyshkin @AkihiroSuda @cyphar
Closes #2786
2021-02-24 18:29:27 +11:00
Kir Kolyshkin 65116710dd Merge pull request #2757 from kolyshkin/test-int-cleanups
tests/int: cleanups
2021-02-23 20:50:17 -08:00
Daniel Dao c3ffd2ef81 Do not convert blkio weight value using blkio->io conversion scheme
bfq weight controller (i.e. io.bfq.weight if present) is still using the
same bfq weight scheme (i.e 1->1000, see [1].) Unfortunately the
documentation for this was wrong, and only fixed recently [2].

Therefore, if we map blkio weight to io.bfq.weight, there's no need to
do any conversion. Otherwise, we will try to write invalid value which
results in error such as:

```
time="2021-02-03T14:55:30Z" level=error msg="container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: process_linux.go:458: setting cgroup config for procHooks process caused: failed to write \"7475\": write /sys/fs/cgroup/runc-cgroups-integration-test/test-cgroup/io.bfq.weight: numerical result out of range"
```

[1] https://github.com/torvalds/linux/blob/master/Documentation/block/bfq-iosched.rst
[2] https://github.com/torvalds/linux/commit/65752aef0a407e1ef17ec78a7fc31ba4e0b360f9

Signed-off-by: Daniel Dao <dqminh89@gmail.com>
2021-02-23 19:46:16 -08:00
Kir Kolyshkin 38b2dd391d runc exec: report possible OOM kill
An exec may fail due to memory shortage (cgroup memory limits being too
tight), and an error message provided in this case is clueless:

> $ sudo ../runc/runc exec xx56 top
> ERRO[0000] exec failed: container_linux.go:367: starting container process caused: read init-p: connection reset by peer

Same as the previous commit for run/start, check the OOM kill counter
and report an OOM kill.

The differences from run are

1. The container is already running and OOM kill counter might not be
   zero.  This is why we have to read the counter before exec and after
   it failed.

2. An unrelated OOM kill event might occur in parallel with our exec
   (and I see no way to find out which process was killed, except to
   parse kernel logs which seems excessive and not very reliable).
   This is why we report _possible_ OOM kill.

With this commit, the error message looks like:

> ERRO[0000] exec failed: container_linux.go:367: starting container process caused: process_linux.go:105: possibly OOM-killed caused: read init-p: connection reset by peer

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:16:33 -08:00
Kir Kolyshkin 5d0ffbf9c8 runc start/run: report OOM
In some cases, container init fails to start because it is killed by
the kernel OOM killer. The errors returned by runc in such cases are
semi-random and rather cryptic. Below are a few examples.

On cgroup v1 + systemd cgroup driver:

> process_linux.go:348: copying bootstrap data to pipe caused: write init-p: broken pipe

> process_linux.go:352: getting the final child's pid from pipe caused: EOF

On cgroup v2:

> process_linux.go:495: container init caused: read init-p: connection reset by peer

> process_linux.go:484: writing syncT 'resume' caused: write init-p: broken pipe

This commits adds the OOM method to cgroup managers, which tells whether
the container was OOM-killed. In case that has happened, the original error
is discarded (unless --debug is set), and the new OOM error is reported
instead:

> ERRO[0000] container_linux.go:367: starting container process caused: container init was OOM-killed (memory limit too low?)

Also, fix the rootless test cases that are failing because they expect
an error in the first line, and we have an additional warning now:

> unable to get oom kill count" error="no directory specified for memory.oom_control

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:15:33 -08:00
Kir Kolyshkin 7e137b9044 libct/cg/fs2/hugetlb: use fscommon.GetValueByKey
This makes the code simpler and more future-proof, in case
any more values will appear in hugetlb.*.events.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Kir Kolyshkin 9fa65f6607 libct/cg/fscommon: add GetValueByKey
Generalize the libct/getValueFromCgroup() as fscommon.GetValueByKey(),
and document it.

No changes other than using fscommon.ParseUint to convert the value.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Kir Kolyshkin c54c3f852d libcontainer/notify_linux_v2: use fscommon.ReadFile
This is to benefit from openat2() implementation, on kernels
that support it. Theoretically this also improves security.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Kir Kolyshkin 494f900e91 libct/cg/fscommon: rename/facelift GetCgroupParamKeyValue
1. This is the only function in the package with Get prefix
   that does not read a file (but parses a string). Rename
   accordingly, and convert the callers.

	GetCgroupParamKeyValue -> ParseKeyValue

2. Use strings.Split rather than strings.Fields. Split by a space
   is 2x faster, plus we can limit the splitting. The downside is
   we have to strip a newline in one of the callers.

3. Improve the doc and the code flow.

4. Fix a test case with invalid data (spaces at BOL).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Kir Kolyshkin 1880d2fc05 libct/cg/fs/memory: handle EBUSY
EBUSY when trying to set memory limit may mean the new limit is too low
(lower than the current usage, and the kernel can't do anything).
Provide a more specific error for such case.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Kir Kolyshkin 27fd3fc3ce libct/cg/fs: setMemoryAndSwap: refactor
1. Factor out setMemory and setSwap
2. Pass cgroup.Resources (rather than cgroup) to setMemoryAndSwap().
3. Merge the duplicated "set memory, set swap" case.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Kir Kolyshkin 3cced523a5 libct/cg/fs/memory: optimize Set
Currently, we read and parse 5 different files while we only need 1.

Use GetCgroupParamUint() directly to get current limit.

While at it, remove the workaround previously needed for the unit test,
and make it a bit more verbose.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Kir Kolyshkin 65c2d3c2b6 tests/int/update: add test case for PR #592
Add integration test coverage for code initially added by commit
d8b8f76c4f ("Fix problem when update memory and swap memory",
2016-04-05).

This is in addition to existing unit test,
TestMemorySetSwapSmallerThanMemory.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-23 16:11:55 -08:00
Mrunal Patel f36d64d683 Merge pull request #2814 from kolyshkin/systemd-apply
libct/cgroups/systemd: don't set limits in Apply
2021-02-23 15:16:43 -08:00
Mrunal Patel e00273e09d Merge pull request #2816 from odinuge/cgroup-v2-cache
Fix memory stats for cache in fs2
2021-02-23 14:59:42 -08:00
Akihiro Suda f245b8c207 Merge pull request #2815 from hnts/update_readme 2021-02-23 22:12:42 +09:00
Ryosuke Hanatsuka 53d3b5524a Update README.md for libcontainer
Signed-off-by: Ryosuke Hanatsuka <hanatsuu@gmail.com>
2021-02-23 11:21:34 +09:00
Odin Ugedal 6c5ed0db3a Fix memory stats for cache in fs2
In cgroup v2, the "cache" value from cgroup v1 is called "file" in v2.
There are no values called "cache" in v2.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/memcontrol.c?id=31caf8b2a847214be856f843e251fc2ed2cd1075#n1521
Signed-off-by: Odin Ugedal <odin@uged.al>
2021-02-22 12:27:12 +01:00
Kir Kolyshkin ee06c700dc Merge pull request #2804 from Iceber/filemode
libcontainer: fix the file mode of the device
2021-02-22 00:57:21 -08:00
Kir Kolyshkin af521ed580 libct/cgroups/systemd: don't set limits in Apply
All cgroup managers has Apply() and Set() methods:

 - Apply is used to create a cgroup (and, in case of systemd,
   a systemd unit) and/or put a PID into the cgroup (and unit);

 - Set is used to set various cgroup resources and limits.

The fs/fs2 cgroup manager implements the functionality as described above.

The systemd v1/v2 manager deviate -- it sets *most* of cgroup limits
(those that can be projected to systemd unit properties) in Apply(),
and then again *all* cgroup limits in Set (first indirectly via systemd
properties -- same as in Apply, then via cgroupfs).

This commit removes setting the cgroup limits from Apply,
so now the systemd manager behaves the same way as the fs manager.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-19 18:53:24 -08:00
Iceber Gu fa52df9493 libcontainer: fix the file mode of the device
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-02-17 15:08:22 +08:00
Akihiro Suda f245a1d1ed Merge pull request #2808 from kolyshkin/go116-final 2021-02-17 10:50:03 +09:00
Mrunal Patel 06c1cd8896 Merge pull request #2806 from kolyshkin/readme-gha-badges
README: add gha badges
2021-02-16 14:50:30 -08:00
Kir Kolyshkin 91f0ae1884 ci/gha: bump go 1.16-rc1 -> 1.16.x
As the final go 1.16 is released, rc1 is no longer available.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-16 12:30:05 -08:00
Kir Kolyshkin 5b14a26164 README: add gha badges
Note that validate currently fails on master -- this is tracked
in https://github.com/opencontainers/runc/issues/2627.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-10 14:39:27 -08:00
Mrunal Patel 824e4ad3b8 Merge pull request #2803 from AkihiroSuda/fix-arch-apparmor
apparmor: try attr/apparmor/exec before attr/exec
2021-02-10 10:29:13 -08:00
Akihiro Suda 9f1365373d Merge pull request #2796 from vasiliy-ul/ebpf-fix-device-access-check
ebpf: fix device access check
2021-02-10 16:37:01 +09:00
Akihiro Suda f3f563bc0f apparmor: try attr/apparmor/exec before attr/exec
Fix issue 2801

Tested on Arch Linux with the following configuration
```
[root@archlinux ~]# pacman -Q runc containerd docker linux
runc 1.0.0rc93-1
containerd 1.4.3-1
docker 1:20.10.3-1
linux 5.10.14.arch1-1

[root@archlinux ~]# cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=bd8aaf58-8735-4fd5-a0c1-804a998f8d57 rw net.ifnames=0 rootflags=compress-force=zstd apparmor=1 lsm=capability,lockdown,yama,bpf,apparmor

[root@archlinux ~]# cat /etc/docker/daemon.json
{
  "runtimes": {
    "runc-tmp": {
      "path": "/tmp/runc"
    }
  }
}

[root@archlinux ~]# docker run -it --rm alpine
docker: Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:495: container init caused: apply apparmor profile: apparmor failed to apply profile: write /proc/self/attr/exec: invalid argument: unknown.

[root@archlinux ~]# docker run -it --rm --runtime=runc-tmp alpine
/ # cat /proc/self/attr/apparmor/current
docker-default (enforce)
/ # cat /proc/self/attr/current
cat: read error: Invalid argument
``

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-10 16:27:13 +09:00
Kir Kolyshkin 41670e21f0 tests/int: rework/simplify setup and teardown
1. Get rid of fixed ROOT, *_BUNDLE, and CONSOLE_SOCKET dirs.
   Now they are temporary directories created in setup_bundle.

2. Automate containers cleanup: instead of having to specify all
   containers to be removed, list and destroy everything (which is
   now possible since every test case has its own unique root).

3. Randomize cgroup paths so two tests running in parallel won't
   use the same cgroup.

Now it's theoretically possible to execute tests in parallel.
Practically it's not possible yet because bats uses GNU parallel,
which do not provide a terminal for whatever it executes, and
many runc tests (all those that run containers with terminal:
true) needs a tty. This may possibly be addressed later.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-09 20:05:54 -08:00
Mrunal Patel 2dbfa87477 Merge pull request #2793 from cyphar/cgroup2-ebpf-userns
cgroup2: devices: handle eBPF skipping more correctly
2021-02-09 15:12:12 -08:00
Kir Kolyshkin d73b4443ef ci: enable -race from matrix
Add a new test matrix dimension so all tests are run twice,
with and without race detector.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 16:01:14 -08:00
Kir Kolyshkin b774454736 libct/int: fix a data race
Fix for the following:

$ sudo go test -race -v ./libcontainer/integration/
=== RUN   TestUsernsCheckpoint
==================
WARNING: DATA RACE
Write at 0x00c00019e650 by goroutine 15:
  bytes.(*Buffer).ReadFrom()
      /usr/lib/golang/src/bytes/buffer.go:200 +0x48
  io.copyBuffer()
      /usr/lib/golang/src/io/io.go:395 +0x3fe
  io.Copy()
      /usr/lib/golang/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/golang/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/golang/src/os/exec/exec.go:441 +0x38

Previous write at 0x00c00019e650 by goroutine 12:
  bytes.(*Buffer).ReadFrom()
      /usr/lib/golang/src/bytes/buffer.go:200 +0x48
  io.copyBuffer()
      /usr/lib/golang/src/io/io.go:395 +0x3fe
  io.Copy()
      /usr/lib/golang/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/golang/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/golang/src/os/exec/exec.go:441 +0x38

Goroutine 15 (running) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/golang/src/os/exec/exec.go:440 +0xaaa
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).criuSwrk()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:1490 +0x5f7
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Restore()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:1398 +0x29ef
  github.com/opencontainers/runc/libcontainer/integration.testCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:204 +0x1898
  github.com/opencontainers/runc/libcontainer/integration.TestUsernsCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:48 +0x177
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1123 +0x202

Goroutine 12 (finished) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/golang/src/os/exec/exec.go:440 +0xaaa
  github.com/opencontainers/runc/libcontainer.(*initProcess).start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/process_linux.go:313 +0xda
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:366 +0xb0
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:263 +0x27b
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Run()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:273 +0x46
  github.com/opencontainers/runc/libcontainer/integration.testCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:108 +0x941
  github.com/opencontainers/runc/libcontainer/integration.TestUsernsCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:48 +0x177
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1123 +0x202
==================
==================
WARNING: DATA RACE
Read at 0x00c00019e630 by goroutine 15:
  bytes.(*Buffer).Len()
      /usr/lib/golang/src/bytes/buffer.go:73 +0x58
  bytes.(*Buffer).grow()
      /usr/lib/golang/src/bytes/buffer.go:118 +0x4f
  bytes.(*Buffer).ReadFrom()
      /usr/lib/golang/src/bytes/buffer.go:202 +0x7c
  io.copyBuffer()
      /usr/lib/golang/src/io/io.go:395 +0x3fe
  io.Copy()
      /usr/lib/golang/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/golang/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/golang/src/os/exec/exec.go:441 +0x38

Previous write at 0x00c00019e630 by goroutine 12:
  bytes.(*Buffer).ReadFrom()
      /usr/lib/golang/src/bytes/buffer.go:209 +0x1c4
  io.copyBuffer()
      /usr/lib/golang/src/io/io.go:395 +0x3fe
  io.Copy()
      /usr/lib/golang/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/golang/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/golang/src/os/exec/exec.go:441 +0x38

Goroutine 15 (running) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/golang/src/os/exec/exec.go:440 +0xaaa
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).criuSwrk()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:1490 +0x5f7
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Restore()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:1398 +0x29ef
  github.com/opencontainers/runc/libcontainer/integration.testCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:204 +0x1898
  github.com/opencontainers/runc/libcontainer/integration.TestUsernsCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:48 +0x177
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1123 +0x202

Goroutine 12 (finished) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/golang/src/os/exec/exec.go:440 +0xaaa
  github.com/opencontainers/runc/libcontainer.(*initProcess).start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/process_linux.go:313 +0xda
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:366 +0xb0
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:263 +0x27b
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Run()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:273 +0x46
  github.com/opencontainers/runc/libcontainer/integration.testCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:108 +0x941
  github.com/opencontainers/runc/libcontainer/integration.TestUsernsCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:48 +0x177
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1123 +0x202
==================
==================
WARNING: DATA RACE
Read at 0x00c00019e648 by goroutine 15:
  bytes.(*Buffer).Len()
      /usr/lib/golang/src/bytes/buffer.go:73 +0x7e
  bytes.(*Buffer).grow()
      /usr/lib/golang/src/bytes/buffer.go:118 +0x4f
  bytes.(*Buffer).ReadFrom()
      /usr/lib/golang/src/bytes/buffer.go:202 +0x7c
  io.copyBuffer()
      /usr/lib/golang/src/io/io.go:395 +0x3fe
  io.Copy()
      /usr/lib/golang/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/golang/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/golang/src/os/exec/exec.go:441 +0x38

Previous write at 0x00c00019e648 by goroutine 12:
  bytes.(*Buffer).grow()
      /usr/lib/golang/src/bytes/buffer.go:147 +0x2d7
  bytes.(*Buffer).ReadFrom()
      /usr/lib/golang/src/bytes/buffer.go:202 +0x7c
  io.copyBuffer()
      /usr/lib/golang/src/io/io.go:395 +0x3fe
  io.Copy()
      /usr/lib/golang/src/io/io.go:368 +0x7a
  os/exec.(*Cmd).writerDescriptor.func1()
      /usr/lib/golang/src/os/exec/exec.go:311 +0x4a
  os/exec.(*Cmd).Start.func1()
      /usr/lib/golang/src/os/exec/exec.go:441 +0x38

Goroutine 15 (running) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/golang/src/os/exec/exec.go:440 +0xaaa
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).criuSwrk()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:1490 +0x5f7
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Restore()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:1398 +0x29ef
  github.com/opencontainers/runc/libcontainer/integration.testCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:204 +0x1898
  github.com/opencontainers/runc/libcontainer/integration.TestUsernsCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:48 +0x177
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1123 +0x202

Goroutine 12 (finished) created at:
  os/exec.(*Cmd).Start()
      /usr/lib/golang/src/os/exec/exec.go:440 +0xaaa
  github.com/opencontainers/runc/libcontainer.(*initProcess).start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/process_linux.go:313 +0xda
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:366 +0xb0
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Start()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:263 +0x27b
  github.com/opencontainers/runc/libcontainer.(*linuxContainer).Run()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:273 +0x46
  github.com/opencontainers/runc/libcontainer/integration.testCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:108 +0x941
  github.com/opencontainers/runc/libcontainer/integration.TestUsernsCheckpoint()
      /home/kir/go/src/github.com/opencontainers/runc/libcontainer/integration/checkpoint_test.go:48 +0x177
  testing.tRunner()
      /usr/lib/golang/src/testing/testing.go:1123 +0x202
==================
    testing.go:1038: race detected during execution of test
--- FAIL: TestUsernsCheckpoint (0.62s)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 15:33:24 -08:00
Kir Kolyshkin c34a9b1025 tests/int/hooks.bats: don't use DEBIAN_BUNDLE
1. Do not depend on $DEBIAN_BUNDLE, instead use the current directory.

2. Simplify setup() by calling teardown().

3. In teardown(), check that LIBPATH is set.

4. Move global variables into setup.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:49:04 -08:00
Kir Kolyshkin e40a369ea8 tests/int/list.bats: don't use $BUSYBOX_BUNDLE
Use the value of $(pwd) as we cd to bundle dir before running a test.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:47:27 -08:00
Kir Kolyshkin 985546b445 tests/int: BATS_TMPDIR -> BATS_RUN_TMPDIR
It's a little known fact, but BATS_TMPDIR is just /tmp, and it is not
being cleaned by bats after the test.

BATS_RUN_TMPDIR (available since bats 1.2.1) is $BATS_TMPDIR/bats-run-$$
(i.e. it is per bats run and includes PID), and it is cleaned up after
the test (unless --no-tmpdir-cleanup is given).

Use BATS_RUN_TMPDIR for better isolation and cleanup.

[v2: check for BATS_RUN_TMPDIR, effectively requiring bats >= 1.2.1]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:46:58 -08:00
Kir Kolyshkin 85d5fea468 tests/int: stop reusing HELLO_BUNDLE for alt root
Overloading $HELLO_BUNDLE with a second purpose of having an alternative
runc root is confusing.

Instead, let's create a temp directory in setup() and clean it up in
teardown().

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin 76532fac03 tests/int/events: rm unneeded eval
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin 497661406e tests/int: use wait_for_container where appropriate
... instead of more generic "retry", to simplify code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin 4d6ffa39a0 tests/int/helpers: reimplement wait_for_container
... by using retry, to avoid code duplication.

While at it, make it check the number of arguments and error out on
invalid usage.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin e7052dcd83 tests/int/spec.bats: don't use HELLO_BUNDLE
All tests are run with cd to bundle directory, so
let's just use $(pwd).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin 0cfc2e327d tests/int: rm teardown_running_container_inroot
It is only used in a couple of places and is easy to replace
with ROOT=xxx teardown_running_container.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin 78f0e4b277 tests/int: rm wait_for_container_inroot
Since commit abd0515816 it is no longed used.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Kir Kolyshkin 64d5702f02 tests/int: don't depend on BUSYBOX_BUNDLE var
All the tests are run with cd to bundle directory, so
it does not make ense to explicitly specify it.

This relies on the feature of functions like set_cgroups_path
or update_config to use current directory by default.

In those cases where we need to change the directory
(runc create/run -b), save the current one and use it later.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-08 12:45:44 -08:00
Vasiliy Ulyanov efb8552b05 tests/int: add device access test
The test verifies if the device file can be queried using
'access(dev_name, F_OK)' when the permissions are set to 'rw'. The call
does not explicitly trigger read or write access but should succeed.

Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
2021-02-08 14:14:14 +01:00