fix: handle extra colons in /proc/self/cgroup entries#35
Merged
Conversation
Use strings.SplitN with limit of 3 instead of strings.Split so that extra colons in the cgroup path (e.g. from Kubernetes cri-containerd) are preserved in the path field rather than causing a parse error. Also fix nil error wrapping in the parse error message.
Collaborator
|
Have we managed to create a reproduction of this issue? My understanding of the source is that the path we extract isn't the full path of the cgroup (although I could be completely misunderstanding, which is why it'd be nice to get a reproduction). // getCgroupsPath generates container cgroups path.
func getCgroupsPath(cgroupsParent, id string) string {
base := path.Base(cgroupsParent)
if strings.HasSuffix(base, ".slice") {
// For a.slice/b.slice/c.slice, base is c.slice.
// runc systemd cgroup path format is "slice:prefix:name".
return strings.Join([]string{base, "cri-containerd", id}, ":")
}
return filepath.Join(cgroupsParent, id)
} |
DanielleMaywood
approved these changes
Mar 4, 2026
Collaborator
DanielleMaywood
left a comment
There was a problem hiding this comment.
Known misconfiguration, we may as well handle it cleanly, approving containerd/containerd#4900
Collaborator
|
Once merged, feel free to create a patch release, and then bump the version used by coder/coder |
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 #34
Problem
On some Kubernetes nodes,
/proc/self/cgroupcontains entries with extra colons in the path:currentProcCgroup()usedstrings.Split(entry, ":")which expected exactly 3 parts. Extra colons produced 4+ parts, causing a parse error that crashed the agent.Additionally, the error message wrapped a nil
errvariable, producing%!w(<nil>)in logs.Fix
strings.SplitN(..., 3)to limit splitting to 3 parts, preserving extra colons in the path field.Tests
Added 3 test cases: