-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix container cgroup under cgroupfs #4080
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
Conversation
In case cgroupfs cgroup manager is used, the container got created under the conmon cgroup (rather than under the root), and then the stats doesn't work because the cgroup path is invalid. For example, if the conmon cgroup is created as /sys/fs/cgroup/pod_123-456/crio-conmon-<ID>, then the container cgroup is created as /sys/fs/cgroup/pod_123-456/crio-conmon-<ID>/pod_123-456/crio-<ID>, rather than sys/fs/cgroup/pod_123-456/crio-conmon-<ID>. The `cricrl stats` then fails as it can't find the container cgroup. This happens because the cgroupsPath set in spec for such containers is not absolute, so the cgroup is created under the current cgroup, which is that of conmon. The fix is easy. Signed-off-by: Kir Kolyshkin <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #4080 +/- ##
=======================================
Coverage 41.17% 41.17%
=======================================
Files 109 109
Lines 9018 9018
=======================================
Hits 3713 3713
Misses 4966 4966
Partials 339 339 |
|
/retest |
saschagrunert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
/retest |
1 similar comment
|
/retest |
|
/lgtm |
|
/retest |
| parent = sbParent | ||
| } | ||
| return filepath.Join(parent, crioPrefix+"-"+containerID) | ||
| return filepath.Join("/", parent, crioPrefix+"-"+containerID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK, but should we be doing a securejoin here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
- This is not an absolute path, but a one relative to /sys/fs/cgroup.
- runc/crun [should] do sanity checks.
- The only untrusted component here is parent, this is a cgroup of sandbox, which is also created by cri-o.
|
/retest |
2 similar comments
|
/retest |
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kolyshkin, mrunalp, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test e2e-aws |
|
/retest |
|
/test e2e-aws |
|
CI is all green now, although |
What type of PR is this?
/kind bug
What this PR does / why we need it:
In case cgroupfs cgroup manager is used, the container got created under
the conmon cgroup (rather than under the root), and then the stats
doesn't work because the cgroup path is invalid.
For example, if the conmon cgroup is created as
/sys/fs/cgroup/pod_123-456/crio-conmon-, then the container cgroup
is created as
/sys/fs/cgroup/pod_123-456/crio-conmon-/pod_123-456/crio-,
rather than sys/fs/cgroup/pod_123-456/crio-conmon-.
The
cricrl statsthen fails as it can't find the container cgroup.This happens because the cgroupsPath set in spec for such containers
is not absolute, so the cgroup is created under the current cgroup,
which is that of conmon.
The fix is easy.
Which issue(s) this PR fixes:
Fixes #4075
Special notes for your reviewer:
Found while working on #4064. That PR has a test case (in test/stats.bats) which will check this issue, so there's no test case in here.
Does this PR introduce a user-facing change?