Repository navigation
fix: read cgroupv2 memory usage from the cgroup that owns memory.max - #39
Open
david-fraley wants to merge 2 commits into
Open
david-fraley wants to merge 2 commits into
david-fraley wants to merge 2 commits into
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This was referenced Oct 23, 2026
DanielleMaywood
approved these changes
Oct 23, 2026
This was referenced Oct 25, 2026
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.
Fixes #38 (CORE-693).
In cgroup v2,
memory()foundmemory.maxby walking up to an ancestor, but still readmemory.currentandmemory.statfrom the process's own cgroup. In docker-in-docker and devcontainer workspaces the agent sits in/init.scopewhile nested containers sit in sibling/docker/<id>, so usage was massively understated (6% reported vs 89% actual) and memory alerts never fired before an OOM kill.Now usage is read from the same cgroup that owns the limit, so used and total describe the same domain. When the process's own cgroup holds the limit, or there is no limit, behavior is unchanged. If the limit owner has no usage files, it falls back to the old behavior.
Added
Memory/UsageFromLimitOwnerwith an/init.scope+/docker/<id>fixture; it fails onmainand passes with this change. CPU may have the same shape (noted in the issue) but is not changed here.Generated by Coder Agents on behalf of @david-fraley.