Commit Graph

4276 Commits

Author SHA1 Message Date
Akihiro Suda 4540b596b8 Fix TestGetContainerStateAfterUpdate on cgroup v2
CI was failing on cgroup v2 because mockCgroupManager.GetUnifiedPath()
was returning an error.

Now the function returns the value of mockCgroupManager.unifiedPath,
but the value is currently not used in the tests.

Fix #2286

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-04-03 09:12:38 +09:00
Mrunal Patel 0c6659ac8e
Merge pull request #2261 from AkihiroSuda/vagrant-kvm
vagrant: switch from VirtualBox to KVM + increase HW resources
2020-04-02 15:55:35 -07:00
Michael Crosby f8e138855d
Merge pull request #2280 from kolyshkin/errors-unwrap
Use errors.Unwrap() where possible
2020-04-02 14:39:06 -04:00
Michael Crosby 6ca9d8e6da
Merge pull request #2283 from tedyu/runc-path-in-prefix
isPathInPrefixList return value should be reverted
2020-04-02 14:09:49 -04:00
Michael Crosby b26e4f27c1
Merge pull request #2284 from tedyu/criu-svr-close
Avoid double close of criuServer
2020-04-02 14:07:35 -04:00
Mrunal Patel e3e26cafe9
Merge pull request #2276 from kolyshkin/criu-v2
cgroupv2: don't use GetCgroupMounts for criu c/r
2020-04-01 17:36:24 -07:00
Mrunal Patel 22a2c9a4bf
Merge pull request #2282 from kolyshkin/cgroupv2-getpaths
libct/isPaused: don't use GetPaths from v2 code
2020-04-01 17:35:48 -07:00
Ted Yu 49896ab0f4 Avoid double close of criuServer
Signed-off-by: Ted Yu <yuzhihong@gmail.com>
2020-04-01 16:15:23 -07:00
Ted Yu d02fc48422 isPathInPrefixList return value should be reverted
Signed-off-by: Ted Yu <yuzhihong@gmail.com>
2020-04-01 15:45:31 -07:00
Kir Kolyshkin 8d7977ee6e libct/isPaused: don't use GetPaths from v2 code
Using GetPaths from cgroupv2 unified hierarchy code is deprecated
and this function will (hopefully) be removed.

Use GetUnifiedPath() for v2 case.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 20:24:28 -07:00
Kir Kolyshkin 12e156f076 libct.isPaused: use errors.Unwrap
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 20:07:04 -07:00
Kir Kolyshkin 272c83e169 libct/cgroups: use errors.Unwrap
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 20:07:04 -07:00
Kir Kolyshkin bd737f1e94 libct/cgroups/fs: use errors.Unwrap
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 20:07:04 -07:00
Kir Kolyshkin d2dfc635ea libct/cgroups/fs2: use errors.Unwrap
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 20:07:04 -07:00
Kir Kolyshkin e4e35b8de8 libct/cgroups/fscommon.WriteFile: use errors.Unwrap
Tested that the EINTR is still being detected:

> $ go1.14 test -c # 1.14 is needed for EINTR to happen
> $ sudo ./fscommon.test
> INFO[0000] interrupted while writing 1063068 to /sys/fs/cgroup/memory/test-eint-89293785/memory.limit_in_bytes
> PASS

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 20:07:04 -07:00
Kir Kolyshkin 66778b3c28 libct/setKernelMemory: use errors.Unwrap
This simplifies code a lot.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 20:07:04 -07:00
Akihiro Suda b8eed86ea9 vagrant: switch from VirtualBox to KVM + increase HW resources
* Switch from VirtualBox to KVM because GCE (used in Travis) doesn't officially support VirtualBox:
https://cloud.google.com/compute/docs/instances/enable-nested-virtualization-vm-instances

* Increase HW resources: 512MB -> 2GB, 1 vCPU -> 2 vCPUs

* Cache /home/travis/.vagrant.d/boxes

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-04-01 09:32:24 +09:00
Kir Kolyshkin fc840f199f cgroupv2: don't use GetCgroupMounts for criu c/r
When performing checkpoint or restore of cgroupv2 unified hierarchy,
there is no need to call getCgroupMounts() / cgroups.GetCgroupMounts()
as there's only a single mount in there.

This eliminates the last internal (i.e. runc) use case of
cgroups.GetCgroupMounts() for v2 unified. Unfortunately, there
are external ones (e.g. moby/moby) so we can't yet let it
return an error.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 17:05:11 -07:00
Michael Crosby 9ec5b03e5a
Merge pull request #2259 from adrianreber/v2-test
Add minimal cgroup2 checkpoint/restore support
2020-03-31 15:01:18 -04:00
Michael Crosby 8221d999f3
Merge pull request #2279 from masters-of-cats/freezer
Actually check for syscall.ENODEV when checking if a container is paused
2020-03-31 14:59:20 -04:00
Michael Crosby 92a3f80ef8
Merge pull request #2203 from mrunalp/systemd_conn_cleanup
Separate systemd dbus connection initialization from running check
2020-03-31 14:58:24 -04:00
Yulia Nedyalkova 2abc6a3605 Actually check for syscall.ENODEV when checking if a container is paused
It turns out that ioutil.Readfile wraps the error in a *os.PathError.
Since we cannot guarantee compilation with golang >= v1.13, we are
manually unwrapping the error.

Signed-off-by: Kieron Browne <kbrowne@pivotal.io>
2020-03-31 15:52:20 +01:00
Adrian Reber 3e99aa3628
Fix checkpoint/restore tests on Fedora 31
The Travis tests running on Fedora 31 with cgroup2 on Vagrant had the
CRIU parts disabled because of a couple of problems.

One problem was a bug in runc and CRIU handling that Andrei fixed.

In addition four patches from the upcoming  CRIU 3.14 are needed for
minimal cgroup2 support (freezer and mounting of cgroup2). With Andrei's
fix and the CRIU cgroup2 support and the runc CRIU cgroup2 integration
it is now possible the checkpoint integration tests again on the Fedora
Vagrant cgroup2 based integration test.

To run CRIU based tests the modules of Fedora 31 (the test host system)
are mounted inside of the container used to test runc in the buster
based container with -v /lib/modules:/lib/modules.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-03-31 16:36:36 +02:00
Adrian Reber 9a0184b10f
cgroup2: use CRIU's new freezer v2 support
The newest CRIU version supports freezer v2 and this tells runc
to use it if new enough or fall back to non-freezer based process
freezing on cgroup v2 system.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-03-31 16:36:35 +02:00
Mrunal Patel d05e5728aa systemd: Lazy initialize the systemd dbus connection
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2020-03-30 15:24:06 -07:00
Mrunal Patel 33c6125da6 systemd: Export IsSystemdRunning() function
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
2020-03-30 15:24:06 -07:00
Akihiro Suda 4a9e1747da
Merge pull request #2234 from thaJeztah/debian_buster
Dockerfile: some refactoring, and switch to "buster" variant
2020-03-31 06:50:12 +09:00
Sebastiaan van Stijn dca34a0417
Dockerfile: switch to "buster" variant (current stable)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-30 21:59:28 +02:00
Sebastiaan van Stijn 48bf88c40e
Dockerfile: prevent busting build-cache for busybox rootfs
Move adding the source code to the end, so that the busybox rootfs
doesn't have to be fetched again on each code change.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-30 21:59:26 +02:00
Sebastiaan van Stijn a596387689
Dockerfile: sort dependencies, and cleanup apt cache
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-30 21:59:24 +02:00
Sebastiaan van Stijn c4821c2bd8
Dockerfile: set DEBIAN_FRONTEND=noninteractive
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-30 21:59:21 +02:00
Sebastiaan van Stijn 201152a976
Dockerfile: use build-args to allow overriding versions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-30 21:59:17 +02:00
Michael Crosby 8df45c891f
Merge pull request #2268 from AkihiroSuda/vendor-20200325
update vendor
2020-03-30 14:06:36 -04:00
Akihiro Suda ad6d577ab5 travis: run `make verify-dependencies` with Go 1.14.x
Background: https://github.com/opencontainers/runc/pull/2073#issuecomment-596068439

> switched back to running the vendoring in 1.14. If we vendor with go
> 1.13, go build will fail on go 1.14, making the tests fil.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-30 18:24:21 +09:00
Akihiro Suda dfc1b0cd51 update vendor
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-28 04:22:06 +09:00
Mrunal Patel f1eea9051c
Merge pull request #2275 from kolyshkin/scan-nits
bifio.Scan.Err usage nits
2020-03-27 11:41:06 -07:00
Mrunal Patel 53ad1d5100
Merge pull request #2256 from kolyshkin/mountinfo-alt
Use faster mountinfo parser (part 1)
2020-03-27 11:36:51 -07:00
Mrunal Patel 75ff40cd28
Merge pull request #2273 from kolyshkin/v2-untangle
cgroup v2 cleanups
2020-03-27 11:21:36 -07:00
Kir Kolyshkin aab2c8ba52 libcontainer/intelrdt: optimize parseCpuInfoFile
The line we are parsing looks like this

> flags		: fpu vme de pse <...>

so look for "flags" as a prefix, not substring.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-27 00:41:11 -07:00
Kir Kolyshkin 0af5cd2041 Nit: fix use of bufio.Scanner.Err
The Err() method should be called after the Scan() loop, not inside it.

Found by

 git grep -A3 -F '.Scan()' | grep Err

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-27 00:12:17 -07:00
Qiang Huang d4a6a1d998
Merge pull request #2258 from masters-of-cats/eintr-retry
Retry writing to cgroup files on EINTR error
2020-03-27 11:21:41 +08:00
Kir Kolyshkin b45db5d3b2 libcontainer/cgroup: obsolete Get*Cgroup for v2
These functions should not be called from any code handling
the cgroup2 unified hierarchy.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-26 19:20:00 -07:00
Kir Kolyshkin a949e4f22f cgroupv2: UnifiedManager.Apply: simplify
Remove joinCgroupsV2() function, as its name and second parameter
are misleading. Use createCgroupsv2Path() directly, do not call
getv2Path() twice.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-26 19:20:00 -07:00
Kir Kolyshkin 5406833a65 cgroupv2/systemd: add getv2Path
Function getSubsystemPath(), while works for v2 unified case, is
suboptimal, as it does a few unnecessary calls.

Add a simplified version of getSubsystemPath(), called getv2Path(),
and use it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-26 19:17:09 -07:00
Mrunal Patel cebef0ee86
Merge pull request #2272 from kolyshkin/cgroupv2-max
cgroupv2: use "max" for negative values
2020-03-26 15:33:57 -07:00
Kir Kolyshkin ec1f957b23 cgroupv2: don't use getSubsystemPath in Apply
This code is a copy-paste from cgroupv1 systemd code. Its aim
is to check whether a subsystem is available, and skip those
that are not.

In case v2 unified hierarchy is used, getSubsystemPath never
returns "not found" error, so calling it is useless.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-26 13:32:34 -07:00
Kir Kolyshkin 6905b72154 cgroupv2: use "max" for negative values
Cgroup v1 kernel doc [1] says:

> We can write "-1" to reset the ``*.limit_in_bytes(unlimited)``.

and cgroup v2 kernel documentation [2] says:

> - If a controller implements an absolute resource guarantee and/or
>  limit, the interface files should be named "min" and "max"
>  respectively.  If a controller implements best effort resource
>  guarantee and/or limit, the interface files should be named "low"
>  and "high" respectively.
>
>  In the above four control files, the special token "max" should be
>  used to represent upward infinity for both reading and writing.

Allow -1 value to still be used for v2, converting it to "max"
where it makes sense to do so.

This fixes the following issue:

> runc update test_update --memory-swap -1:
> error while setting cgroup v2: [write /sys/fs/cgroup/machine.slice/runc-cgroups-integration-test.scope/memory.swap.max: invalid argument
> failed to write "-1" to "/sys/fs/cgroup/machine.slice/runc-cgroups-integration-test.scope/memory.swap.max"
> github.com/opencontainers/runc/libcontainer/cgroups/fscommon.WriteFile
> 	/home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/fscommon/fscommon.go:21
> github.com/opencontainers/runc/libcontainer/cgroups/fs2.setMemory
> 	/home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/fs2/memory.go:20
> github.com/opencontainers/runc/libcontainer/cgroups/fs2.(*manager).Set
> 	/home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/fs2/fs2.go:175
> github.com/opencontainers/runc/libcontainer/cgroups/systemd.(*UnifiedManager).Set
> 	/home/kir/go/src/github.com/opencontainers/runc/libcontainer/cgroups/systemd/unified_hierarchy.go:290
> github.com/opencontainers/runc/libcontainer.(*linuxContainer).Set
> 	/home/kir/go/src/github.com/opencontainers/runc/libcontainer/container_linux.go:211

[1] linux/Documentation/admin-guide/cgroup-v1/memory.rst
[2] linux/Documentation/admin-guide/cgroup-v2.rst

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-26 11:14:32 -07:00
Mrunal Patel 96596cbbec
Merge pull request #2270 from kolyshkin/systemd-no-kmem
cgroupv2: don't try to set kmem for systemd case
2020-03-25 21:39:52 -07:00
Kir Kolyshkin a675b5ebea cgroupv2: don't try to set kmem for systemd case
To the best of my knowledge, it has been decided to drop the kernel
memory controller from the cgroupv2 hierarchy, so "kernel memory limits"
do not exist if we're using v2 unified.

So, we need to ignore kernel memory setting. This was already done in
non-systemd case (see commit 88e8350de), let's do the same for systemd.

This fixes the following error:

> container_linux.go:349: starting container process caused "process_linux.go:306: applying cgroup configuration for process caused \"open /sys/fs/cgroup/machine.slice/runc-cgroups-integration-test.scope/tasks: no such file or directory\""

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-25 20:00:23 -07:00
Mrunal Patel be51398a8a
Merge pull request #2193 from milkwine/fix-readSync
fix readSync
2020-03-24 14:29:42 -07:00