Skip to content

Conversation

@ashahab-altiscale
Copy link
Contributor

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]

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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]>
@ashahab-altiscale
Copy link
Contributor Author

@hqhq @mrunalp @wking I have changed the PR to comply with the case (2) discussed here: #397

@LK4D4
Copy link
Contributor

LK4D4 commented Nov 17, 2015

Looks like everything about cgroups should be relative.

@mrunalp
Copy link
Contributor

mrunalp commented Nov 17, 2015

Yep, relative to the cgroup mount point.

@ashahab-altiscale
Copy link
Contributor Author

Thanks. @wking Can this be farther clarified in your doc PR(can't find the link to it)

@wking
Copy link
Contributor

wking commented Nov 18, 2015

On Tue, Nov 17, 2015 at 09:30:23PM -0800, Abin Shahab wrote:

@wking Can this be farther clarified in your doc PR(can't find the
link to it)

The PR I spun off from #397 is opencontainers/runtime-spec#247, but 1
already has:

cgroupsPath is expected to be relative to the cgroups mount
point. If not specified, cgroups will be created under '/'.

which I think covers both cases pretty clearly (as far as relative
paths are concerned). What more would you like?

@ashahab-altiscale
Copy link
Contributor Author

@wking , you are right, this is clear that cgroupsPath must be relative. Therefore there is no point in it being a full path.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrunalp I removed it.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

@ashahab-altiscale ashahab-altiscale force-pushed the 396-cgroupsPath branch 4 times, most recently from bf059ec to 1b6360e Compare December 10, 2015 23:17
@ashahab-altiscale
Copy link
Contributor Author

@mrunalp Made the changes you requested. Devices cgroup uses os.stat to check existence of cgroupsPath, and decides accordingly.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, @LK4D4 @mrunalp and I have discussed this, and the current behavior in runc(if operator provides parent, it will append parent to Name) should be sufficient.

@LK4D4
Copy link
Contributor

LK4D4 commented Dec 15, 2015

Yes, Name field is sorta confusing. But it was like this even before.

@crosbymichael crosbymichael modified the milestones: 0.0.8, 0.0.9 Feb 4, 2016
@LK4D4 LK4D4 closed this in #497 Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants