From 4b2b978291275ab243fc84a3ad68551e70f39837 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Thu, 14 Mar 2019 10:24:04 -0700 Subject: [PATCH 1/5] Add cgroup name to error message More information should help troubleshoot an issue when this error occurs. Signed-off-by: Filipe Brandenburger --- libcontainer/specconv/spec_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcontainer/specconv/spec_linux.go b/libcontainer/specconv/spec_linux.go index a1579892363..f68cac011a6 100644 --- a/libcontainer/specconv/spec_linux.go +++ b/libcontainer/specconv/spec_linux.go @@ -325,7 +325,7 @@ func createCgroupConfig(opts *CreateOpts) (*configs.Cgroup, error) { // for e.g. "system.slice:docker:1234" parts := strings.Split(myCgroupPath, ":") if len(parts) != 3 { - return nil, fmt.Errorf("expected cgroupsPath to be of format \"slice:prefix:name\" for systemd cgroups") + return nil, fmt.Errorf("expected cgroupsPath to be of format \"slice:prefix:name\" for systemd cgroups, got %q instead", myCgroupPath) } c.Parent = parts[0] c.ScopePrefix = parts[1] From a9056a348f1741572937ed73084dfee49e579b9f Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Wed, 13 Mar 2019 20:10:38 -0700 Subject: [PATCH 2/5] Add $RUNC_USE_SYSTEMD to use systemd cgroup driver in tests This allows us to test runc using libcontainer's systemd driver, by passing an extra `--systemd-cgroup` argument to the calls to runc. Tested: $ sudo make localintegration TESTPATH='/exec.bats' RUNC_USE_SYSTEMD=1 And confirmed that systemd was in use by looking at creation and removal of libcontainer__systemd_test_default.slice test slices. Also introduced a breakage in systemd cgroup driver and confirmed that the tests failed as expected. Signed-off-by: Filipe Brandenburger --- tests/integration/exec.bats | 2 +- tests/integration/helpers.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/exec.bats b/tests/integration/exec.bats index c598718dee8..0ff2e6364b5 100644 --- a/tests/integration/exec.bats +++ b/tests/integration/exec.bats @@ -133,7 +133,7 @@ function teardown() { runc run -d --console-socket $CONSOLE_SOCKET test_busybox [ "$status" -eq 0 ] - run bash -c "cat hello > preserve-fds.test; exec 3 preserve-fds.test; exec 3 Date: Thu, 14 Mar 2019 14:37:34 -0700 Subject: [PATCH 3/5] Update tests that depend on cgroupfs paths to consider systemd cgroups When $RUNC_USE_SYSTEMD is set, then use a systemd syntax for the cgroupsPath. Also fix $CGROUPS_PATH to look under the actual path to the slice/scope created by systemd. Tested: $ sudo make localintegration TESTPATH='/cgroups.bats' RUNC_USE_SYSTEMD=1 That test will fail without this commit. Signed-off-by: Filipe Brandenburger --- tests/integration/helpers.bash | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 809b47677ae..14181332873 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -39,7 +39,11 @@ CONSOLE_SOCKET="$BATS_TMPDIR/console.sock" # Cgroup paths CGROUP_MEMORY_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') CGROUP_CPU_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') -CGROUPS_PATH="/runc-cgroups-integration-test/test-cgroup" +if [[ -n "${RUNC_USE_SYSTEMD}" ]] ; then + CGROUPS_PATH="/machine.slice/runc-cgroups-integration-test.scope" +else + CGROUPS_PATH="/runc-cgroups-integration-test/test-cgroup" +fi CGROUP_MEMORY="${CGROUP_MEMORY_BASE_PATH}${CGROUPS_PATH}" # CONFIG_MEMCG_KMEM support @@ -118,7 +122,11 @@ function runc_rootless_cgroup() { # Helper function to set cgroupsPath to the value of $CGROUPS_PATH function set_cgroups_path() { bundle="${1:-.}" - sed -i 's/\("linux": {\)/\1\n "cgroupsPath": "\/runc-cgroups-integration-test\/test-cgroup",/' "$bundle/config.json" + cgroups_path="/runc-cgroups-integration-test/test-cgroup" + if [[ -n "${RUNC_USE_SYSTEMD}" ]] ; then + cgroups_path="machine.slice:runc-cgroups:integration-test" + fi + sed -i 's#\("linux": {\)#\1\n "cgroupsPath": "'"${cgroups_path}"'",#' "$bundle/config.json" } # Helper function to set a resources limit From 5369f9ade35d39a1bf12caa00600f1ffc77340e0 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Thu, 14 Mar 2019 14:48:41 -0700 Subject: [PATCH 4/5] Skip CRIU tests when $RUNC_USE_SYSTEMD for now These tests sometimes hang, so let's skip them for now. Tested: $ sudo make localintegration TESTPATH='/checkpoint.bats' RUNC_USE_SYSTEMD=1 The 5 tests in this test suite will be skipped. Signed-off-by: Filipe Brandenburger --- tests/integration/checkpoint.bats | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration/checkpoint.bats b/tests/integration/checkpoint.bats index 92fe559e042..87696df6ee9 100644 --- a/tests/integration/checkpoint.bats +++ b/tests/integration/checkpoint.bats @@ -3,6 +3,10 @@ load helpers function setup() { + if [[ -n "${RUNC_USE_SYSTEMD}" ]] ; then + skip "CRIU test suite is skipped on systemd cgroup driver for now." + fi + teardown_busybox setup_busybox } From 9fe7c939f8e652bfbd7a8474f4a295fdb5430911 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Thu, 14 Mar 2019 18:48:56 -0700 Subject: [PATCH 5/5] Add a Travis-CI job for systemd cgroup driver The additional test shows as a separate job. It sets environment RUNC_USE_SYSTEMD=1 so it will be clear in Travis-CI that this job is testing the systemd cgroup driver. Signed-off-by: Filipe Brandenburger --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index f04be04ddbd..bf5298909eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,13 @@ go: - tip matrix: + include: + - go: 1.11.x + env: + - RUNC_USE_SYSTEMD=1 + script: + - make BUILDTAGS="${BUILDTAGS}" all + - sudo PATH="$PATH" make localintegration RUNC_USE_SYSTEMD=1 allow_failures: - go: tip