Skip to content

Commit da90947

Browse files
committed
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 #4772). Due to item 2, modify some tests accordingly. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent f24aa06 commit da90947

File tree

7 files changed

+40
-15
lines changed

7 files changed

+40
-15
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.4.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.2
17+
github.com/opencontainers/cgroups v0.0.3
1818
github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67
1919
github.com/opencontainers/selinux v1.12.0
2020
github.com/seccomp/libseccomp-golang v0.11.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g
4545
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
4646
github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q=
4747
github.com/mrunalp/fileutils v0.5.1/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
48-
github.com/opencontainers/cgroups v0.0.2 h1:A+mAPPMfgKNCEZUUtibESFx06uvhAmvo8sSz3Abwk7o=
49-
github.com/opencontainers/cgroups v0.0.2/go.mod h1:s8lktyhlGUqM7OSRL5P7eAW6Wb+kWPNvt4qvVfzA5vs=
48+
github.com/opencontainers/cgroups v0.0.3 h1:Jc9dWh/0YLGjdy6J/9Ln8NM5BfTA4W2BY0GMozy3aDU=
49+
github.com/opencontainers/cgroups v0.0.3/go.mod h1:s8lktyhlGUqM7OSRL5P7eAW6Wb+kWPNvt4qvVfzA5vs=
5050
github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67 h1:Q+KewUGTMamIe6Q39xCD/T1NC1POmaTlWnhjikCrZHA=
5151
github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
5252
github.com/opencontainers/selinux v1.12.0 h1:6n5JV4Cf+4y0KNXW48TLj5DwfXpvWlxXplUkdTrmPb8=

tests/integration/helpers.bash

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

354354
if [ -v CGROUP_V2 ]; then
355-
local weight=$((1 + ((shares - 2) * 9999) / 262142))
355+
# Same formula as ConvertCPUSharesToCgroupV2Value.
356+
local weight
357+
weight=$(awk -v shares="$shares" '
358+
BEGIN {
359+
if (shares == 0) { print 0; exit }
360+
if (shares <= 2) { print 1; exit }
361+
if (shares >= 262144) { print 10000; exit }
362+
l = log(shares) / log(2)
363+
exponent = (l*l + 125*l) / 612.0 - 7.0/34.0
364+
print int(exp(exponent * log(10)) + 0.99)
365+
}')
366+
356367
check_cpu_weight "$weight"
357368
else
358369
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
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/config_linux.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/utils.go

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

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ github.com/moby/sys/userns
5151
# github.com/mrunalp/fileutils v0.5.1
5252
## explicit; go 1.13
5353
github.com/mrunalp/fileutils
54-
# github.com/opencontainers/cgroups v0.0.2
54+
# github.com/opencontainers/cgroups v0.0.3
5555
## explicit; go 1.23.0
5656
github.com/opencontainers/cgroups
5757
github.com/opencontainers/cgroups/devices

0 commit comments

Comments
 (0)