Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 6119e53

Browse files
kolyshkinjaredledvina
authored andcommitted
deps: bump cgroups to v0.0.3, fix tests
For changelog, see https://github.com/opencontainers/cgroups/releases/tag/v0.0.3 This fixes two runc issues: 1. JSON incompatibility introduced in cgroups v0.0.2 (see opencontainers/cgroups#22). 2. Bad CPU shares to CPU weight conversion (see opencontainers#4772). Due to item 2, modify some tests accordingly. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 9a2420e commit 6119e53

File tree

20 files changed

+148
-101
lines changed

20 files changed

+148
-101
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/moby/sys/user v0.3.0
1515
github.com/moby/sys/userns v0.1.0
1616
github.com/mrunalp/fileutils v0.5.1
17-
github.com/opencontainers/cgroups v0.0.1
17+
github.com/opencontainers/cgroups v0.0.3
1818
github.com/opencontainers/runtime-spec v1.2.1
1919
github.com/opencontainers/selinux v1.11.1
2020
github.com/seccomp/libseccomp-golang v0.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g
4949
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
5050
github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q=
5151
github.com/mrunalp/fileutils v0.5.1/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
52-
github.com/opencontainers/cgroups v0.0.1 h1:MXjMkkFpKv6kpuirUa4USFBas573sSAY082B4CiHEVA=
53-
github.com/opencontainers/cgroups v0.0.1/go.mod h1:s8lktyhlGUqM7OSRL5P7eAW6Wb+kWPNvt4qvVfzA5vs=
52+
github.com/opencontainers/cgroups v0.0.3 h1:Jc9dWh/0YLGjdy6J/9Ln8NM5BfTA4W2BY0GMozy3aDU=
53+
github.com/opencontainers/cgroups v0.0.3/go.mod h1:s8lktyhlGUqM7OSRL5P7eAW6Wb+kWPNvt4qvVfzA5vs=
5454
github.com/opencontainers/runtime-spec v1.2.1 h1:S4k4ryNgEpxW1dzyqffOmhI1BHYcjzU8lpJfSlR0xww=
5555
github.com/opencontainers/runtime-spec v1.2.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
5656
github.com/opencontainers/selinux v1.11.1 h1:nHFvthhM0qY8/m+vfhJylliSshm8G1jJ2jDMcgULaH8=

tests/integration/helpers.bash

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,18 @@ function check_cpu_shares() {
344344
local shares=$1
345345

346346
if [ -v CGROUP_V2 ]; then
347-
local weight=$((1 + ((shares - 2) * 9999) / 262142))
347+
# Same formula as ConvertCPUSharesToCgroupV2Value.
348+
local weight
349+
weight=$(awk -v shares="$shares" '
350+
BEGIN {
351+
if (shares == 0) { print 0; exit }
352+
if (shares <= 2) { print 1; exit }
353+
if (shares >= 262144) { print 10000; exit }
354+
l = log(shares) / log(2)
355+
exponent = (l*l + 125*l) / 612.0 - 7.0/34.0
356+
print int(exp(exponent * log(10)) + 0.99)
357+
}')
358+
348359
check_cpu_weight "$weight"
349360
else
350361
check_cgroup_value "cpu.shares" "$shares"

tests/integration/update.bats

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,9 @@ EOF
545545
runc run -d --console-socket "$CONSOLE_SOCKET" test_update
546546
[ "$status" -eq 0 ]
547547

548-
# check that initial values were properly set
548+
# Check that initial values (from setup) were properly set.
549549
check_cpu_quota 500000 1000000 "500ms"
550-
# initial cpu shares of 100 corresponds to weight of 4
551-
check_cpu_weight 4
550+
check_cpu_shares 100
552551
check_systemd_value "TasksMax" 20
553552

554553
runc update -r - test_update <<EOF

vendor/github.com/opencontainers/cgroups/RELEASES.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/cgroups/config_linux.go

Lines changed: 51 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/cgroups/devices/config/device.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/cgroups/devices/devices_emulator.go

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/cgroups/devices/systemd.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/cgroups/fs/freezer.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)