Skip to content

cgroup2: confusing error when linux.resources.cpu.shares=1 #4755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
corhere opened this issue May 1, 2025 · 1 comment
Open

cgroup2: confusing error when linux.resources.cpu.shares=1 #4755

corhere opened this issue May 1, 2025 · 1 comment

Comments

@corhere
Copy link
Contributor

corhere commented May 1, 2025

When passed a spec with an out-of-range CPU shares value, runc will fail to start the container and reports an error message. On a cgroup1 host the returned error message makes it clear which part of the container config is the problem.

minimum allowed cpu-shares is 2

However, on a cgroup2 host, the error message makes no mention of CPU shares.

failed to write "70369281052672": write /sys/fs/cgroup/.../cpu.weight: numerical result out of range
$ docker run --rm --cpu-shares 1 hello-world
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error setting cgroup config for procHooks process: failed to write "70369281052672": write /sys/fs/cgroup/docker/4139b57a20695ff4f62dda799b1c4052791f59bac4611534cb3a213a3e446add/cpu.weight: numerical result out of range: unknown.

It is not at all obvious that a CPU weight of 70369281052672 has anything to do with "shares": 1 in the container config.

Expected: runc returns an error message which flags the CPU shares configuration as being out of range, irrespective of the host system's configuration.

Why this is a runc bug

@kolyshkin
Copy link
Contributor

Good analysis, thanks @corhere.

Fix part 1: opencontainers/cgroups#17

(part 2 is to switch to the new conversion function and return an error early)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants