-
Notifications
You must be signed in to change notification settings - Fork 2.2k
CgroupsPath in runC #399
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
CgroupsPath in runC #399
Conversation
26e5f06 to
33344e9
Compare
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.
Sorry I don't understand your PR, why set cgroupsPath to name? cgroupsPath should be a relative or absolute path, not just a cgroup name.
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.
@hqhq Cgroups path is expected to be a path relative to the cgroups mount: https://github.com/opencontainers/specs/blob/master/runtime_config_linux.go#L29
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.
@ashahab-altiscale I think the problem here is name should not identify a cgroup, because it should just be the name, not the full path.
In the code, cgroup path can be affected by parent besides name, though it won't happen in real life for now because we only support parent for Docker and Docker don't use cgroupsPath. But that'll be tricky if we want to expand these features in the future.
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.
We should remove parent as you and @LK4D4 discussed. CgroupsPath must not be a full path, but relative to cgroup mount on host. That's what I interpret from spec.
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.
Also, since cgroupsPath does not support split hierarchy, would parent be ever different than what this line retrieves: https://github.com/opencontainers/runc/blob/master/spec.go#L436
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.
Sorry for the confusing, here all cgroup path I mentioned are relative to cgroup mount point, and full path I meat absolute path including cgroup name, like /web/apache/apache1, here I think what name should be is apache1, not the entire /web/apache/apache1.
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 understand now, thanks for explanation. However, this name can also be a
path, since it gets appended to the cgroup mount.
On Nov 18, 2015 12:16 AM, "Qiang Huang" [email protected] wrote:
In spec.go
#399 (comment):@@ -438,6 +438,9 @@ func createCgroupConfig(name string, spec _specs.LinuxRuntimeSpec, devices []_co
if err != nil {
return nil, err
}
- if spec.Linux.CgroupsPath != "" {
name = spec.Linux.CgroupsPath- }
Sorry for the confusing, here all cgroup path I mentioned are relative to
cgroup mount point, and full path I meat absolute path including cgroup
name, like /web/apache/apache1, here I think what name should be is
apache1, not the entire /web/apache/apache1.—
Reply to this email directly or view it on GitHub
https://github.com/opencontainers/runc/pull/399/files#r45170849.
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.
@hqhq I just tested this with cgroupsPath with test1/test2/test3 as a cgroupsPath, and the behavior is as expected. I have test1/test2/test3 cgroup created before starting runc.
When I do runc start it appropriately joins and modifies test3 cgroup.
Do you have other comments on my approach?
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.
@mrunalp @crosbymichael Any feedback on this? This will allow me to launch containers inside userns containers.
This sets up the cgroupsPath. If cgroupsPath is passed in, runC will check if the cgroup exists. If it exists, runC will just join the cgroup, and will not make any modifications to the cgroups. If it does not exist, runC will create the cgroup and join it. Signed-off-by: Abin Shahab <[email protected]>
33344e9 to
2363d45
Compare
|
Looks like everything about cgroups should be relative. |
|
Yep, relative to the cgroup mount point. |
|
Thanks. @wking Can this be farther clarified in your doc PR(can't find the link to it) |
|
On Tue, Nov 17, 2015 at 09:30:23PM -0800, Abin Shahab wrote:
The PR I spun off from #397 is opencontainers/runtime-spec#247, but 1 cgroupsPath is expected to be relative to the cgroups mount which I think covers both cases pretty clearly (as far as relative |
|
@wking , you are right, this is clear that cgroupsPath must be relative. Therefore there is no point in it being a full path. |
libcontainer/configs/cgroup_unix.go
Outdated
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.
We shouldn't have a bool for this. If there is a path passed, then we use it. Resource may or may not be empty.
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.
@mrunalp I removed it.
e2cf52e to
b70705c
Compare
libcontainer/cgroups/fs/apply_raw.go
Outdated
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.
We shouldn't require this right? If there is a path passed in then we use that path.
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.
removed.
bf059ec to
1b6360e
Compare
Signed-off-by: Abin Shahab <[email protected]>
1b6360e to
f115082
Compare
|
@mrunalp Made the changes you requested. Devices cgroup uses os.stat to check existence of cgroupsPath, and decides accordingly. |
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.
We use a combination of parent and the name to derive the path. So, you need to handle the parent as well and make sure it is correct.
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 think it was like this before. We used path as Name in docker for cgroup-parent.
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.
|
Yes, Name field is sorta confusing. But it was like this even before. |
This sets up the cgroupsPath. If cgroupsPath is passed in, runC will
check if the cgroup exists. If it exists, runC will just join the
cgroup, and will not make any modifications to the cgroups unless explicitly asked for.
If it does not exist, runC will create the cgroup and join it.
Signed-off-by: Abin Shahab [email protected]