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

Conversation

@jaredledvina
Copy link
Member

This PR cherry-picks the commits from both opencontainers#4751 and opencontainers#4785 to ultimately backport the "Bad CPU shares to CPU weight conversion" fix from the latter PR to runc 1.3.

Instead of providing systemd CPU quota value (CPUQuotaPerSec),
calculate it based on how opencontainers/cgroups/systemd handles
it (see addCPUQuota).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
For changes, see https://github.com/opencontainers/cgroups/releases/tag/v0.0.2

Fix integration tests according to changes in [1] (now the CPU quota value set
is rounded the same way systemd does it).

[1]: opencontainers/cgroups#4
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Since opencontainers/cgroups v0.0.2 (commit b206a01), all stuct
Resources fields are annotated with "omitempty" attribute.
As a result, the loaded configuration may have Resources == nil.

It is totally OK (rootless containers may have no resources configured)
except since commit 6c5441e, cgroup v1 fs manager requires Resources to
be set in the call to NewManager (this is a cgroup v1 deficiency,
or maybe our implementation deficiency, or both).

To work around this, let's add code to ensure Resources is never nil
after loading from state.json.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
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 <kolyshkin@gmail.com>
@jaredledvina jaredledvina requested a review from a team September 23, 2025 17:16
@jaredledvina jaredledvina merged commit 6716915 into v1.3-dd Sep 24, 2025
34 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants