-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
set default cgroup path to /runc #895
Conversation
So far when "cgroupsPath" was not specified in the config.json file runC containers used the prefix associated with the "devices" subsystem and placed the container in a subhierarchy starting with prefix for all subystems. For example, if the user starting the container was located in "/sys/fs/cgroup/devices/user.slice/random-cgroup" then runC would retrieve the "/user.slice/random-cgroup" string and place the container in a subcgroup "/sys/fs/cgroup/*/user.slice/random-cgroup/CONTAINERNAME" for all subsystems. Let's rather use "/runc" as the default cgroup for all subsystems. This seems cleaner and falls in line with Docker/LXC et al. Signed-off-by: Christian Brauner <cbrauner@suse.com>
This is part of #892. |
WDYT @mrunalp @crosbymichael @hqhq ? |
👍 |
I'm currently trying to codify some of the |
No, I don't think that is correct. If you want a default cgroup path then you place it in the config. The reason why it nests itself in its parents cgroup path is to support things like being run under systemd. You can omit cgroup settings from the spec and place them in your service file. Then you just add runc as your command in the service file and the cgroups are correct and what you would expect. If you have a hard coded default like this then when running under other supervisors and such it will cause unexpected things . |
@crosbymichael, I don't understand what you mean by "it nests itself in its parents cgroup path". The problem I see is that it retrieves a random subcgroup from one cgroup, namely the devices subsystem, and takes that as the root cgroup for all other subsystems. That is if your are in the subcgroup
then the current implementation will lead to you being placed in:
which does not seem to be nesting in its parents cgroup path (e.g. the devices parent cgroup path is totally different from the pids parent cgroup path). Also, I'd argue that this is a rather arbitrary approach.
This is more in line with what you e.g. expect from Docker and I currently fail to see how this would be a problem for e.g. supervisord or other daemons that deal with cgroups. As long as init mounts cgroupf at |
Docker wants its own sub path and it sets it, there is no need to makeup a new default.
And if I launch a service from a .service file and i don't have any cgroups specified i expect it to be inside the cgroups that systemd setup.
|
For context, cgroups won't have the concept of one process in different hierarchies overtime. There will be a unified hierarchy where all of the controllers exist for one group. Instead of how things are often done today where there is a hierarchy per controller. I agree with @crosbymichael that this isn't a good default. |
@philips Currently runtime-spec doesn't support unified hierarchies. It's a bit odd of a restriction, because you can have unified hierarchies with cgroupv1 as well (but runC is broken in that case too: #798). But the thing that @brauner is referring to is that if you do this (with
Which is a bug whether or not you believe that we should nest under parent cgroups (which is what @crosbymichael thinks is a good default). Currently we nest under the devices cgroup and then use that path for all other cgroups -- what we can do to fix this is to make an unspecified The important thing to note is that the code won't have to change in a unified hierarchy -- it'll just be a special case where all of the parent paths are the same. |
Sorry, maybe you misunderstood. I was just citing Docker as an example that uses a nice clean default for the cgroups it places itself in, namely
This behavior will not be altered by this commit.
As @cyphar said, this specific change does not affect cgroup v1 vs v2. |
I agree there is issue with current approach, I think what @crosbymichael and @philips concerned is how we choose the default cgroup, a named I would vote to remove the default unified cgroup path, and just create a cgroup named
@opencontainers/runc-maintainers WDYT? |
@hqhq, that's basically what I did. The only difference is that I'd append |
Also I'd argue it's not random. It's the default approach for nearly all container runtimes. But I'm repeating myself. I'm fine with whatever you do as long as it is not as arbitrary as picking up the default cgroup prefix from the devices controller. |
@brauner runc already have |
@hqhq we already embed in the parent when no cgroupPath is specified. I think this is the best default and if you want more control you just set the cgroupPath. If you want something explicit then just set it, I don't want a hard coded default because it would be harder or require an extra flag to tell runc to embed it.
@brauner thanks for the PR but lets keep the default to embedding the cgroup in its parent and if you want to set something explicit, just add cgroupPath in the spec. |
Alternative of opencontainers#895 , part of opencontainers#892 The intension of current behavior if to create cgroup in parent cgroup of current process, but we did this in a wrong way, we used devices cgroup path of current process as the default parent path for all subsystems, this is wrong because we don't always have the same cgroup path for all subsystems. Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
@crosbymichael See #1009 |
Alternative of opencontainers#895 , part of opencontainers#892 The intension of current behavior if to create cgroup in parent cgroup of current process, but we did this in a wrong way, we used devices cgroup path of current process as the default parent path for all subsystems, this is wrong because we don't always have the same cgroup path for all subsystems. Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Alternative of opencontainers#895 , part of opencontainers#892 The intension of current behavior if to create cgroup in parent cgroup of current process, but we did this in a wrong way, we used devices cgroup path of current process as the default parent path for all subsystems, this is wrong because we don't always have the same cgroup path for all subsystems. Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
So far when "cgroupsPath" was not specified in the config.json file runC
containers used the prefix associated with the "devices" subsystem and placed
the container in a subhierarchy starting with prefix for all subystems. For
example, if the user starting the container was located in
"/sys/fs/cgroup/devices/user.slice/random-cgroup" then runC would retrieve the
"/user.slice/random-cgroup" string and place the container in a subcgroup
"/sys/fs/cgroup/*/user.slice/random-cgroup/CONTAINERNAME" for all subsystems.
Let's rather use "/runc" as the default cgroup for all subsystems. This seems
cleaner and falls in line with Docker/LXC et al.
Signed-off-by: Christian Brauner cbrauner@suse.com