Commit Graph

4524 Commits

Author SHA1 Message Date
Akihiro Suda 54c53b10d3
Merge pull request #2533 from XiaodongLoong/fix_cgMode_redundant
use criu cgroup mode const from go-criu
2020-08-13 12:13:24 +09:00
Mrunal Patel a2d1f85be0
Merge pull request #2542 from AkihiroSuda/go1.15
upgrade Go to 1.15
2020-08-12 09:08:15 -07:00
Akihiro Suda 4c71a68c6e
upgrade Go to 1.15
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-08-12 15:37:25 +09:00
Mrunal Patel dedadbf9ea
Merge pull request #2545 from kolyshkin/go-mod-vendor
Makefile: fix go vet/fmt
2020-08-10 07:41:04 -07:00
Mrunal Patel 809dc64041
Merge pull request #2548 from kolyshkin/int-cr-fix
tests/int: fix error handling and logging
2020-08-10 07:39:29 -07:00
Xiaodong Liu 7f64fb4786 use criu cgroup mode const from go-criu
Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
2020-08-10 10:25:53 +08:00
Kir Kolyshkin 5026bfab9c tests/int: fix error handling and logging
TL;DR: this allows to show logs from failed runc restore.

Bats scripts are run with `set -e`. This is well known and obvious,
and yet there are a few errors with respect to that, including a few
"gems" by yours truly.

1. bats scripts are run with `set -e`, meaning that `[ $? -eq 0 ]` is
   useless since the execution won't ever reach this line in case of
   non-zero exit code from a preceding command. So, remove all such
   checks, they are useless and misleading.

2. bats scripts are run with `set -e`, meaning that `ret=$?` is useless
   since the execution won't ever reach this line in case of non-zero
   exit code from a preceding command.

In particular, the code that calls runc restore needs to save the exit
code, show the errors in the log, and only when check the exit code and
fail if it's non-zero. It can not use `run` (or `runc` which uses `run`)
because of shell redirection that we need to set up.

The solution, implemented in this patch, is to use code like this:

```bash
ret=0
__runc ... || ret=$?
show_logs
[ $ret -eq 0 ]
```

In case __runc exits with non-zero exit code, `ret=$?` is executed, and
it always succeeds, so we won't fail just yet and have a chance to show
logs before checking the value of $ret.

In case __runc succeeds, `ret=$?` is never executed, so $ret will still
be zero (this is the reason why it needs to be set explicitly).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-08-08 20:33:04 -07:00
Kir Kolyshkin 985bd24f62 Makefile: fix go vet/fmt
I have noticed that `go vet` from golang 1.13 ignores the vendor/
subdir, downloading all the modules when invoked in Travis CI env.

As the other go commands, in 1.13 it needs explicit -mod=vendor
flag, so let's provide one.

PS once golang 1.13 is unsupported, we will drop it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-08-06 19:18:09 -07:00
Kir Kolyshkin a340fa9b56
Merge pull request #2543 from mrunalp/release_1.0.0-rc92
Release 1.0.0 rc92
2020-08-05 21:49:10 -07:00
Mrunal Patel 1ff1bf3452 VERSION: back to development
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2020-08-05 09:34:30 -07:00
Mrunal Patel ff819c7e91 VERSION: release 1.0.0-rc92
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2020-08-05 09:26:49 -07:00
Akihiro Suda f668854938
Merge pull request #2499 from kolyshkin/find-cgroup-mountpoint-fastpath
cgroupv1/FindCgroupMountpoint: add a fast path
2020-08-04 14:06:41 +09:00
Akihiro Suda 234d15ecd0
Merge pull request #2520 from thaJeztah/bump_runtime_spec
vendor: update runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6
2020-08-04 14:05:33 +09:00
Akihiro Suda 78d02e8563
Merge pull request #2534 from adrianreber/go-criu-4-1-0
Pass location of CRIU binary to go-criu
2020-08-03 16:21:50 +09:00
Kir Kolyshkin 3de3112c61
Merge pull request #2525 from adrianreber/external-pidns
Tell CRIU to use an external pid namespace if necessary
2020-07-31 17:50:27 -07:00
Adrian Reber 6f4616dd73
Pass location of CRIU binary to go-criu
If the CRIU binary is in a non $PATH location and passed to runc via
'--criu /path/to/criu', this information has not been passed to go-criu
and since the switch to use go-criu for CRIU version detection, non
$PATH CRIU usage was broken. This uses the newly added go-criu interface
to pass the location of the binary to go-criu.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-07-31 11:14:15 +02:00
Adrian Reber 267b7148cb
Upgrade go-criu to 4.1.0
Signed-off-by: Adrian Reber <areber@redhat.com>
2020-07-31 11:14:15 +02:00
Akihiro Suda d6f5641c20
Merge pull request #2507 from kolyshkin/alt-to-2497
libct/cgroups/GetCgroupRoot: make it faster
2020-07-31 11:43:38 +09:00
Mrunal Patel 46243fcea1
Merge pull request #2500 from kolyshkin/fs-apply
libct/cgroups/fs: rework Apply()
2020-07-30 16:39:53 -07:00
Kir Kolyshkin e0c0b0cf32 libct/cgroups/GetCgroupRoot: make it faster
...by checking the default path first.

Quick benchmark shows it's about 5x faster on an idle system, and the
gain should be much more on a system doing mounts etc.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-07-30 13:45:21 -07:00
Sebastiaan van Stijn 901dccf05d
vendor: update runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-07-30 22:08:54 +02:00
Akihiro Suda 97b02cf9c0
Merge pull request #2531 from JFHwang/gomod_update
Update go.mod
2020-07-31 03:32:32 +09:00
John Hwang 5935296367 Update go.mod
Signed-off-by: John Hwang <john.f.hwang@gmail.com>
2020-07-30 05:28:39 -07:00
Aleksa Sarai 67169a9d43
merge branch 'pr-2529'
Aleksa Sarai (1):
  devices: correctly check device types

LGTMs: @AkihiroSuda @mrunalp
Closes #2529
2020-07-29 12:13:11 +10:00
Aleksa Sarai 95a59bf206
devices: correctly check device types
(mode&S_IFCHR == S_IFCHR) is the wrong way of checking the type of an
inode because the S_IF* bits are actually not a bitmask and instead must
be checked using S_IF*. This bug was neatly hidden behind a (major == 0)
sanity-check but that was removed by [1].

In addition, add a test that makes sure that HostDevices() doesn't give
rubbish results -- because we broke this and fixed this before[2].

[1]: 24388be71e ("configs: use different types for .Devices and .Resources.Devices")
[2]: 3ed492ad33 ("Handle non-devices correctly in DeviceFromPath")

Fixes: b0d014d0e1 ("libcontainer: one more switch from syscall to x/sys/unix")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-07-28 19:04:30 +10:00
Adrian Reber 09e103b01e
Tell CRIU to use an external pid namespace if necessary
Trying to checkpoint a container out of pod in cri-o fails with:

  Error (criu/namespaces.c:1081): Can't dump a pid namespace without the process init

Starting with the upcoming CRIU release 3.15, CRIU can be told to ignore
the PID namespace during checkpointing and to restore processes into an
existing network namespace.

With the changes from this commit and CRIU 3.15 it is possible to
checkpoint a container out of a pod in cri-o.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-07-27 10:14:08 +02:00
Adrian Reber 610c5ad75c
Factor out checkpointing with external namespace code
To checkpoint and restore a container with an external network namespace
(like with Podman and CNI), runc tells CRIU to ignore the network
namespace during checkpoint and restore.

This commit moves that code to their own functions to be able to reuse
the same code path for external PID namespaces which are necessary for
checkpointing and restoring containers out of a pod in cri-o.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-07-27 10:14:07 +02:00
Kir Kolyshkin d65df61dc5
Merge pull request #2521 from zvier/master
cleancode: clean code for utils_linux.go
2020-07-23 12:58:24 -07:00
zvier 92e2175de1 cleancode: clean code for utils_linux.go
Signed-off-by: Jeff Zvier <zvier20@gmail.com>
2020-07-23 06:12:27 +08:00
Kir Kolyshkin 86d9399c80
Merge pull request #2524 from adrianreber/fix-travis
Fix .travis.yml warnings
2020-07-22 11:16:24 -07:00
Adrian Reber b7683d6b0f
Fix .travis.yml warnings
Travis reports following warnings which are fixed with this commit.

   root: deprecated key sudo (The key `sudo` has no effect anymore.)
   root: missing os, using the default linux
   root: key matrix is an alias for jobs, using jobs

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-07-21 10:27:48 +02:00
Aleksa Sarai f8749ba098
merge branch 'pr-2509'
Kir Kolyshkin (2):
  tests/int/checkpoint: fds and pids cleanup
  tests/int/checkpoint: don't remove readonly flag

LGTMs: @mrunalp @AkihiroSuda @cyphar
Closes #2509
2020-07-20 13:03:38 +10:00
Kir Kolyshkin f9850afa91
Merge pull request #2518 from XiaodongLoong/redundant_chroot_param
remove redundant parameter of chroot function
2020-07-15 17:26:24 -07:00
Xiaodong Liu af283b3f47 remove redundant the parameter of chroot function
Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
2020-07-15 16:22:07 +08:00
Mrunal Patel b7d8f3bf0d
Merge pull request #2516 from ide-rea/fix-typo
fix small typo
2020-07-13 09:04:31 -07:00
Mrunal Patel 47fbafb7bc
Merge pull request #2510 from kolyshkin/criu-el7
tests/centos7: add criu
2020-07-13 07:51:08 -07:00
Xiaoyu Zhang 76b05e6d13 fix small typo
Signed-off-by: Xiaoyu Zhang <mateuszhang@tencent.com>
2020-07-11 16:36:32 +08:00
Mrunal Patel cf1273abf4
Merge pull request #2498 from kolyshkin/v1-code-cleanups
libct/cgroups/fs: code cleanups
2020-07-09 15:58:06 -07:00
Mrunal Patel 545ebdd14a
Merge pull request #2511 from kolyshkin/fedora-dnf-fix
tests/fedora32: retry dnf
2020-07-08 21:20:05 -07:00
Kir Kolyshkin fbf047bf2f
Merge pull request #2501 from XiaodongLoong/systemderror-fix
fix TestPidsSystemd and TestRunWithKernelMemorySystemd test error
2020-07-08 20:39:39 -07:00
Xiaodong Liu f57bb2fe3d fix TestPidsSystemd and TestRunWithKernelMemorySystemd test error
Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
2020-07-09 09:36:03 +08:00
Mrunal Patel ce54a9d4d7
Merge pull request #2514 from rhatdan/windows
Allow libcontainer/configs to be imported on Windows
2020-07-08 14:00:54 -07:00
Kir Kolyshkin 6d5125f8b4 tests/int/checkpoint: don't remove readonly flag
This should not longer be necessary (in theory, at least),
let's see how it goes.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-07-08 12:56:25 -07:00
Kir Kolyshkin 9806eb5567
Merge pull request #2513 from lsm5/custom-PREFIX-in-Makefile
allow customizable PREFIX variable
2020-07-08 12:54:11 -07:00
Daniel J Walsh d78ee47154
Allow libcontainer/configs to be imported on Windows
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-08 15:20:37 -04:00
Kir Kolyshkin 5517d1d71d
Merge pull request #2505 from XiaodongLoong/redundant-copy-src
fix redundant source code copy issue
2020-07-08 07:37:55 -07:00
Kir Kolyshkin ffe9f0b0fb Vagrantfile.centos7: do not ignore script failures
Add `set -e -u -o pipefail` so the script will fail early
if there's an error.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-07-08 07:32:41 -07:00
Lokesh Mandvekar bc1a9c11a2 allow customizable PREFIX variable
This change would let me specify my own PREFIX so that I can reuse
Makefile targets for building rpm packages.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2020-07-08 09:20:03 -04:00
Kir Kolyshkin a73ce38d16 cgroupv1/FindCgroupMountpoint: add a fast path
In case cgroupPath is under the default cgroup prefix, let's try to
guess the mount point by adding the subsystem name to the default
prefix, and resolving the resulting path in case it's a symlink.

In most cases, given the default cgroup setup, this trick
should result in returning the same result faster, and avoiding
/proc/self/mountinfo parsing which is relatively slow and problematic.

Be very careful with the default path, checking it is
 - a directory;
 - a mount point;
 - has cgroup fstype.

If something is not right, fall back to parsing mountinfo.

While at it, remove the obsoleted comment about mountinfo parsing.  The
comment belongs to findCgroupMountpointAndRootFromReader(), but rather
than moving it there, let's just remove it, since it does not add any
value in understanding the current code.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-07-07 13:57:33 -07:00
Kir Kolyshkin c27b8e7fe7 tests/fedora32: retry dnf
Fedora mirrors are not very stable recently, leading to CI failures
that usually look like this:

> sudo: make: command not found

In fact it's caused by dnf failure to read metadata from mirrors:

> Errors during downloading metadata for repository 'updates':
>    - Downloading successful, but checksum doesn't match. Calculated: <....>
> Error: Failed to download metadata for repo 'updates': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

The error went undetected due to lack of exit code check.

This commit:
 - adds `set -e -u -o pipefail` so the script will fail early;
 - adds a retry loop with a sleep around dnf invocation.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-07-07 12:31:52 -07:00