Commit Graph

4858 Commits

Author SHA1 Message Date
Kir Kolyshkin 90d02ecc2a Vagrantfile.centos7: clean up after bats install
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-16 00:41:10 -08:00
Kir Kolyshkin a91210f499 gha: use ssh -tt to have a tty
Github Actions execution environments lack tty, which is needed for
integration tests. We have used script utility before to provide a fake
tty, but it appears to be buggy on CentOS 7.

Since we use ssh anyway to access Vagant VM, add -tt to forcefully
allocate a tty.

Apparently, neither "TERM=xterm" nor "stty size" is needed for
any tests to work, so remove those, too.

Finally, unit tests do not need a terminal, so remove the "script"
from those.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-16 00:40:44 -08:00
Mrunal Patel dbbe7e60c7 Merge pull request #2722 from thaJeztah/warn_freeze
libcontainer: signalAllProcesses(): log warning when failing to thaw
2021-01-13 16:42:42 -08:00
Mrunal Patel 364ada608e Merge pull request #2714 from kolyshkin/readme-using
README additions
2021-01-13 15:55:33 -08:00
Mrunal Patel 555840a638 Merge pull request #2731 from kolyshkin/fix-int
tests/int/multi-arch.bash: fix busybox URL
2021-01-13 13:42:06 -08:00
Mrunal Patel f973238cb7 Merge pull request #2723 from kolyshkin/tty-race
Fix a race in tty code leading to \r in output
2021-01-12 18:26:52 -08:00
Kir Kolyshkin 5de00ad9d4 tests/int/multi-arch.bash: fix for busybox
Due to https://github.com/docker-library/busybox/pull/94 the URLs
to get busybox has changed, so the current URLs give HTTP 404.

Fix the URLs accordingly.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-11 17:41:28 -08:00
Kir Kolyshkin 9712205ecc Merge pull request #2726 from AkihiroSuda/remove-install-vagrant.sh
Remove script/install-vagrant.sh
2021-01-11 11:03:11 -08:00
Akihiro Suda c8e89b8df5 Remove script/install-vagrant.sh
The script is no longer needed as we migrated from Travis to GHA in #2721

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-01-08 14:39:02 +09:00
Kir Kolyshkin 06a684d6a7 libct/int/TestExecInTTY: repeat the test 300 times
This is to increase the chance to hit the recently fixed race.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-07 13:34:46 -08:00
Kir Kolyshkin fedaa2abed TestExecInTTY: simplify, improve error reporting
Simplify the tty code by using 1 goroutine instead of 2.

Improve error reporting by wrapping the errors.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-07 13:34:41 -08:00
Kir Kolyshkin 719d70d2e3 setupIO: simplify code
There's no need to check err for nil.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-07 13:33:41 -08:00
Kir Kolyshkin 24c05b71fa tty: fix ClearONLCR race
The TestExecInTTY test case is sometimes failing like this:

> execin_test.go:332: unexpected carriage-return in output "PID USER TIME COMMAND\r\n 1 root 0:00 cat\r\n 7 root 0:00 ps\r\n"

or this:

> execin_test.go:332: unexpected carriage-return in output "PID USER TIME COMMAND\r\n 1 root 0:00 cat\n 7 root 0:00 ps\n"

(this is easy to repro with `go test -run TestExecInTTY -count 1000`).

This is caused by a race between

 - an Init() (in this case it is is (*linuxSetnsInit.Init(), but
   (*linuxStandardInit).Init() is no different in this regard),
   which creates a pty pair, sends pty master to runc, and execs
   the container process,

and

 - a parent runc process, which receives the pty master fd and calls
   ClearONLCR() on it.

One way of fixing it would be to add a synchronization mechanism
between these two, so Init() won't exec the process until the parent
sets the flag. This seems excessive, though, as we can just move
the ClearONLCR() call to Init(), putting it right after console.NewPty().

Note that bug only happens in the TestExecInTTY test case, but
from looking at the code it seems like it can happen in runc run
or runc exec, too.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-07 13:33:00 -08:00
Sebastiaan van Stijn 039c47ab82 libcontainer: signalAllProcesses(): log warning when failing to thaw
I noticed this was the only place in this function where we didn't
handle errors on freezing/thawing. Logging as a warning, consistent
with the other cases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-01-07 11:45:11 +01:00
Kir Kolyshkin 17a0dc3162 README: add note about not using runc directly
Inspired-by: https://github.com/opencontainers/runc/issues/2702

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-06 14:53:36 -08:00
Kir Kolyshkin 4bc2aab954 README: add links to misc docs
That way it is easier to find.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-06 14:53:36 -08:00
Kir Kolyshkin 04b7b7d3c3 Merge pull request #2721 from kolyshkin/gha-vm
ci: replace travis with GHA for Fedora 33 and CentOS 7
2021-01-06 14:42:25 -08:00
Kir Kolyshkin 2dc1bf91a4 ci: move Fedora 33 and CentOS 7 tests to gha
...and remove .travis.yml as GHA now covers everything it used to
(unless I overlooked something).

Inspired by https://github.com/containerd/containerd/pull/4279

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 21:03:12 -08:00
Kir Kolyshkin e431fe60f8 ci: move misc validate tasks from travis to gha
Note that `make ci` in Travis included `make test`, but we're already
doing that elsewhere (see .github/workflows/test.yml).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 21:01:32 -08:00
Kir Kolyshkin 7ecba232e9 ci: move cross compile check from travis to gha
In here we have to use Docker, as Ubuntu does not support
all the architectures we're compile-testing here.

Since this is the only step that is using Docker,
there is no sense to separate `make runcimage` from
the rest of it. In case we'll have to use Docker image
more, it will make sense to do so.

While at it, ditch script/tmpmount (added by commit 1735ad788f),
because
 - it required root (because mount);
 - it is probably no longer needed.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 20:45:28 -08:00
Kir Kolyshkin 8ccd39a91b ci: move commit length check from travis to gha
Using https://github.com/tim-actions/commit-message-checker-with-regex

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 20:44:55 -08:00
Kir Kolyshkin 1125ae7835 tests/events.bats: unify duplicated code
There are three tests that only differ in delays (and a few other
minor details line whitespace formatting and number of retries).

Let's unify those so maintaining this code will be easier.

This also implicitly increases the number of retries from 3 to 10
for the non-default --interval tests.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-01-05 20:26:03 -08:00
Mrunal Patel 09523b79d0 Merge pull request #2706 from kolyshkin/netns
libct/configs/validate.sysctl: fix host netns check
2021-01-04 09:57:16 -08:00
Mrunal Patel d745daeac4 Merge pull request #2711 from kolyshkin/2701-followup
libct/int/execin_tty: do help debug a flake
2021-01-04 09:39:51 -08:00
Mrunal Patel ce47909bc8 Merge pull request #2712 from kolyshkin/fix-chdir-II
libct/init_linux: reorder chdir to fix EPERM
2021-01-04 09:32:27 -08:00
Akihiro Suda 5efdc0c5a4 Merge pull request #2678 from xiaochenshen/rdt-rm-init
libcontainer/intelrdt: rm init() from intelrdt.go
2020-12-23 01:41:14 +09:00
Kir Kolyshkin 27268b1a7e tests/int/cwd: add test case for cwd not owned by runc
The test setup is complicated, as we want to run it as non-root,
but we need to create a directory owned by a particular user,
and root is needed for chown. To do that, we hijack enable_idmap.

Now, there is no ideal place to clean up AUX_DIR. A function
cleanup is called after the test to do so. Note that it won't
be called if the test fails.

This was verified to fail before and pass after the
previous commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 13:23:27 -08:00
Peter Hunt d869d05aba libctr/init_linux: reorder chdir
commit 5e0e67d76c moved the chdir to be one of the
first steps of finalizing the namespace of the container.

However, this causes issues when the cwd is not accessible by the user running runc, but rather
as the container user.

Thus, setupUser has to happen before we call chdir. setupUser still happens before setting the caps,
so the user should be privileged enough to mitigate the issues fixed in 5e0e67d76c

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2020-12-18 12:59:02 -08:00
Kir Kolyshkin 8bd3b8786b test: add case for GH #2086
Commit 5e0e67d7 ("fix permission denied") modified some code but
did not provide a test case.

This is a test case that was tested to fail before and succeed after
the above commit.

For more details, see https://github.com/opencontainers/runc/pull/2086

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 12:56:48 -08:00
Kir Kolyshkin cb3dd9d8c7 libct/configs/validate: test for bind-mounted netns
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:32:46 -08:00
Kir Kolyshkin 8e8661e124 libct/configs/validate/sysctl: fix repeated netns checks
In case many net.* sysctls are provided, and we're not running
in the host netns, the function keep repeating isNetNS check
for every such sysctl. This is a waste of resources.

Do the isNetNS check only once, and only if needed.

Note that using sync.Once() is not really needed here; we could
have used a boolean variable to skip the repeated check, but
it looks more idiomatic that way.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:32:39 -08:00
Kir Kolyshkin 2dce06995a libct/configs/validate: fix host netns check
In case nsfs mount (such as /run/docker/netns/xxxx) is provided as
the netns path, the current way of determining whether path is of
host netns or not is not working.

The proper way to check is to do stat(2) and compare dev_t and
inode fields, which is what this commit does.

This is a minimal fix which does not try to optimize repeated
check in case more than one net.* sysctl is given and there is
no error.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:29:13 -08:00
Kir Kolyshkin 77b5d8ab5a Merge pull request #2710 from Creatone/creatone/fscommon-close-fd
libctl/cgroups/fscommon: close fd
2020-12-18 09:09:30 -08:00
Kir Kolyshkin 2143b36835 libct/int/execin_tty: do help debug a flake
Do help to debug https://github.com/opencontainers/runc/issues/2425.

Previous commit 1909051b9c modified the code in the wrong place.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 09:00:33 -08:00
Paweł Szulik e709b8abe0 libctl/cgroups/fscommon: close fd
Signed-off-by: Paweł Szulik <pawel.szulik@intel.com>
2020-12-18 14:32:23 +01:00
Mrunal Patel 2e1c1de9de Merge pull request #2708 from loyou/master
checkProcMount: add /proc/slabinfo to whitelist
2020-12-17 17:31:17 -08:00
Mrunal Patel 2a9d7817d7 Merge pull request #2709 from AkihiroSuda/remove-apparmor-selinux-tags
remove "apparmor" and "selinux" build tags
2020-12-17 17:30:30 -08:00
Xiaochen Shen 325a74ddec libcontainer/intelrdt: rm init() from intelrdt.go
Use sync.Once to init Intel RDT when needed for a small speedup to
operations which do not require Intel RDT.

Simplify IntelRdtManager initialization in LinuxFactory.

Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
2020-12-16 23:37:31 +08:00
Akihiro Suda cb26930680 remove "selinux" build tag (Always compile SELinux support)
The build tag was removed in go-selinux v1.8.0: https://github.com/opencontainers/selinux/pull/132

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-12-16 17:41:11 +09:00
Akihiro Suda 552a1c7bb1 remove "apparmor" build tag (Always compile AppArmor support)
The apparmor tag was introduced in a01ed80 (2014) to make cgo dependency
on libapparmor optional.

However, the cgo dependency was removed in db093f6 (2017), so it is no
longer meaningful to keep apparmor build tag.

Close #2704

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-12-16 17:39:48 +09:00
Feng Sun 48b8eb0952 checkProcMount: add /proc/slabinfo to whitelist
With lxcfs commit, slabinfo should can be mounted:
"proc_fuse: add /proc/slabinfo with slab accounting memcg"
https://github.com/lxc/lxcfs/commit/1cc68c8bfa

Signed-off-by: Feng Sun <loyou85@gmail.com>
2020-12-16 09:40:04 +08:00
Akihiro Suda 544048b865 Merge pull request #2689 from kolyshkin/get-cgroup-mounts-all
libct/cgroup/utils: fix GetCgroupMounts(all=true)
2020-12-08 11:48:13 +09:00
Akihiro Suda 4d8d989404 Merge pull request #2668 from kolyshkin/openat2
libcontainer/cgroups/fscommon: add openat2 support
2020-12-07 14:51:17 +09:00
Akihiro Suda b923ff4373 Merge pull request #2701 from kolyshkin/exec-tty
libct/int/execin_tty: help debug a flake
2020-12-05 09:09:34 +09:00
Akihiro Suda 4b055ff583 Merge pull request #2695 from kolyshkin/linter-nits
Misc linter nits
2020-12-04 12:35:06 +09:00
Kir Kolyshkin 1909051b9c libct/int/execin_tty: help debug a flake
This helps to debug https://github.com/opencontainers/runc/issues/2425

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 17:29:54 -08:00
Mrunal Patel 166068a0ff Merge pull request #2691 from kolyshkin/dont-compile-criu
Dockerfile: use binary criu release; update some ci deps
2020-12-03 16:27:52 -08:00
Kir Kolyshkin 8518317c39 Merge pull request #2407 from piowag/2365-blkio-getstat-update
Update blkio GetStats
2020-12-03 15:46:20 -08:00
Kir Kolyshkin 9792929515 libct/intelrdt: fix a staticcheck warning
> libcontainer/intelrdt/monitoring.go:24:2: SA5001: should check returned error before deferring file.Close() (staticcheck)
> 	defer file.Close()
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00
Kir Kolyshkin 6437086ef5 libct/addCriu*Mount: fix gosimple warning
> libcontainer/container_linux.go:768:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
> 	if strings.HasPrefix(mountDest, c.config.Rootfs) {
> 	^
> libcontainer/container_linux.go:1150:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple)
> 	if strings.HasPrefix(mountDest, c.config.Rootfs) {
> 	^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-03 10:24:27 -08:00