Skip to content
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

Clarify cgroups path handling behavior #834

Closed
wants to merge 1 commit into from

Conversation

mrunalp
Copy link
Contributor

@mrunalp mrunalp commented May 17, 2017

Signed-off-by: Mrunal Patel [email protected]


You can configure a container's cgroups via the `resources` field of the Linux configuration.
Do not specify `resources` unless limits have to be updated.
The runtime MUST create the cgroups specified by the `cgroupsPath` if they don't exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

Which cgroups? Only those needed to fulfil resources, no? Or MUST they create a new devices cgroup even if there is nothing in linux.resources.devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They must create all for the use case of orchestrator preparing the cgroups for you and just be asking the runtime to add the container process to the cgroups.

Copy link
Contributor

@wking wking May 18, 2017

Choose a reason for hiding this comment

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

They must create all for the use case of orchestrator preparing the cgroups for you and just be asking the runtime to add the container process to the cgroups.

How should the runtime distinguish between v1 and v2 cgroups (more on this here)? I think a safer approach for orchestrators would be to tell the runtime to leave cgroups alone and set them up completely in a hook (both creating/initializing any required cgroups and joining the runtime to them). On the other hand, with #237 rejected, there's no clear way to warn the runtime that you'll be messing with cgroups in the hook, so the runtime might be surprised with:

  1. No cgroupsPath or resources, so the runtime creates a new devices cgroup and adds the container process.
  2. Orchestration hook (or other post-create action) creates the cgroups that the orchestrator wants and moves the container process into them.
  3. The runtime looks in the devices cgroup it setup in step 1 and… where did that process go?

Copy link
Member

Choose a reason for hiding this comment

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

They must create all for the use case of orchestrator preparing the cgroups for you and just be asking the runtime to add the container process to the cgroups.

But should the runtime join any extra cgroups? The old language handled this case.

You can configure a container's cgroups via the `resources` field of the Linux configuration.
Do not specify `resources` unless limits have to be updated.
The runtime MUST create the cgroups specified by the `cgroupsPath` if they don't exist.
If `cgroupsPath` is empty, then the behavior is runtime implementation specific.
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 you mean “implementation-defined”.

And I liked the old language (where the runtime could pick a default cgroupsPath much more than the huge hole you poke with an unqualified “implementation-defined”. The runtime could drive all sorts of crazy things unrelated to cgroups through this big loophole.

Copy link
Member

Choose a reason for hiding this comment

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

i think this new sentence is fine and not any more of a "loophole" than the old language

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 this new sentence is fine and not any more of a "loophole" than the old language

With the new language, config authors should not leave cgroupsPath empty unless they have read the implementation-specific docs for any runtime that might consume their config. With the old language… I'm not sure. It looks like this PR (as of 81c9f31) still has the “MAY define the default” line. So what is this new line about? Is it just underlining that the default may not be a fixed string (e.g. maybe the runtime defaults to the container ID), so if you leave this unset you might get new cgroup or might join an existing cgroup? If so, I'd rather clarify that that is what is being implementation-defined. The current language in 81c9f31 supports runtimes which error out on unset cgroupsPath (or ignore hooks, etc., etc.), and I don't think we want to give that much leeway here.

With the old language, config authors could safely leave cgroupsPath empty if they didn't care

Copy link
Member

Choose a reason for hiding this comment

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

I too prefer the old language. What is the reason for this change @mrunalp?

config-linux.md Outdated

The runtime MUST ensure that the container process is attached to the cgroups specified by `cgroupsPath`.
If any property is set under `resources` then the runtime MUST set it for the container.
Check individual properties for any specific handling.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this line? It sounds like “and don't forget to read the rest of the spec!” :p.

Copy link
Member

Choose a reason for hiding this comment

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

fair. this sentence is a bit ambiguous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can take this line out.

config-linux.md Outdated
For example, to run a new process in an existing container without updating limits, `resources` need not be specified.

Runtimes MAY attach the container process to additional cgroup controllers beyond those necessary to fulfill the `resources` settings.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to drop this line. I think the additional attaching is surprising, so if we don't forbid runtimes from doing it (which I don't think we can with runC), I'd like to keep mentioning this as an runtime prerogative.

Copy link
Contributor

Choose a reason for hiding this comment

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

To tie this back into its original motivation, the line you're removing here is descended from @cyphar's 4291fd1, which was part of #493. There is a bit of related discussion here.

Copy link
Member

Choose a reason for hiding this comment

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

i think this sentence can stay

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given my comment above, we would want the runtime to join all the cgroups specified by the cgroupsPath.

Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this line is clearer in light of this comment. So I think this line should stay if runtimes remain free to not join all cgroups (known to the runtime? Mentioned in the spec?), but should be dropped if we start requiring them to join all of those cgroups.

The runtime MUST create the cgroups specified by the `cgroupsPath` if they don't exist.
If `cgroupsPath` is empty, then the behavior is runtime implementation specific.

The runtime MUST ensure that the container process is attached to the cgroups specified by `cgroupsPath`.
Copy link
Member

Choose a reason for hiding this comment

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

In cgroupv1 (which we do support but not explicitly) it is not clear what cgroups are specified by a single path. Could you clarify what was wrong with the old language (which had similar semantics but was more explicit about how different controllers are handled).

Also with cgroupv2 it's not clear what cgroup.controllers should be set to in cgroupsPath. Should it be +everything or just +whatever_is_necessary? The former makes rootless containers no longer possible in an OCI runtime, while the latter should also allow for runtimes to join extra cgroups.

@cyphar
Copy link
Member

cyphar commented May 19, 2017

NACK, I'm not sure I understand the loosening of some of the semantics of cgroupsPath (we spent quite a while getting it to this point and I would prefer if we didn't go back 😉). There's still some more discussion necessary IMO.

@mrunalp
Copy link
Contributor Author

mrunalp commented May 19, 2017

@cyphar @wking Okay, let us consider the 4 cases and then comment on what we would want for each. We can then add/remove/keep the language:

  1. cgroupsPath NOTSET resources NOTSET: We have two options here: don't do anything or make it implementation-defined. Making it implementation defined, gives more flexibility so I am leaning towards that.
  2. cgroupsPath SET resources NOTSET: Considering the orchestrator use case, I was leaning towards joining all the cgroups controllers. We don't know what all resources the orchestrator has set so safest would be to join all. An option would be to additionally allow specifying what controllers should be joined.
  3. cgroupsPath NOTSET resources SET: Here we could have the runtime only join the controllers (at a path of its own choice) required to satisfy the resource requirements or all. I don't have a strong preference as this is least likely to be used in production.
  4. cgroupsPath SET resources SET: Again similar to option 2, we need to figure out whether runtime should join all controllers or only the ones necessary to satisfy the resources. Also, could have an option (like in 2) to specify the controllers explicitly (which would need to be validated as being a superset of controllers required to satisfy resources).

@wking
Copy link
Contributor

wking commented May 19, 2017 via email

@wking
Copy link
Contributor

wking commented May 19, 2017 via email

@vbatts
Copy link
Member

vbatts commented May 24, 2017

Closes: #745

@mrunalp
Copy link
Contributor Author

mrunalp commented Jun 1, 2017

I'll remove line 188 and add more language to clarify what cgroups to join.

@hqhq
Copy link
Contributor

hqhq commented Jun 26, 2017

@mrunalp What exactly issue does this PR try to fix? Seems that there are still some concerns not clarified, can this be moved to post 1.0?

@mrunalp
Copy link
Contributor Author

mrunalp commented Jun 26, 2017

@hqhq I am fine closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants