Repository navigation
Conversation
Add Manager.CPUQuota to read the current cgroup's cpu.max through the public API. Return the quota and period in microseconds, using the existing parser's math.MaxInt64 representation for an unlimited quota. Require both fields on reads and preserve file and parsing errors without changing the shared parser's write behavior. Document that ancestor limits are not combined. Cover finite and unlimited quotas, configuration updates, malformed content, read errors, and kernel readback. Add a README usage example. Fixes containerd#377 Assisted-by: Codex Signed-off-by: linrunlong <linrunlong@bytedance.com>
Contributor
Author
|
Hi @fuweid, could you review this PR? Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Superseded by #404 after renaming the source branch to
fix/cgroup2-cpu-quota. The replacement includes the CI dependency fix.Applications can configure cgroup v2 CPU limits but cannot inspect the quota and period through the public API. Add
Manager.CPUQuota()to read the current cgroup'scpu.max, returning both values in microseconds andmath.MaxInt64for an unlimited quota.The reader requires both fields, preserves file and parsing errors, and reuses the existing parser without changing its write behavior. Ancestor limits are not combined. Includes README usage, filesystem tests, and kernel readback before and after switching to an unlimited quota.
Fixes #377.
Validation
On Linux arm64 (Ubuntu 26.04, cgroup v2, Go 1.22.12):
go test -exec sudo -race -count=1 -timeout=5m -json ./...passed, including the extendedTestCgroupv2CpuStatsagainst the kernel.go test -race ./cgroup2 -run '^TestCPUQuota($|Whitespace$|InvalidContent$|ReadErrors$)' -vpassed as non-root, including permission-denied handling.golangci-lint run --verbose -D errcheckpassed with v2.6.2 (0 issues).The full run skipped existing environment-dependent tests (
TestBlkioStat,TestSelfPath,TestPidPath,TestSystemd240, andTestCgroupv2IOController) and the permission-denied subtest when running as root; the latter passed in the separate non-root run.Linux amd64 cross-build and
go vet ./...also passed. The README example compiled for Linux arm64, and formatting/diff checks passed.Upstream CI: cgroup v2 tests and lint passed on Go 1.22 and 1.23, as did the project and generated-file checks. Both cgroup v1 jobs failed before running tests, during Vagrant plugin setup:
fog-json-1.5.0requiresjson >= 2.19, but Vagrant bundlesjson-2.7.2. See the CI run.AI assistance: Codex assisted with implementation, tests, documentation, and review.