Skip to content

Commit 104385d

Browse files
committed
config-linux: MAY reject an unfit cgroup
It makes sense for runtime to reject a cgroup which is frozen (for both new and existing container), otherwise the runtime command (create/run/exec) may end up being stuck. It makes sense for runtime to make sure the cgroup for a new container is empty (i.e. there are no processes it in), and reject it otherwise. The scenario in which a non-empty cgroup is used for a new container has multiple problems, for example: * If two or more containers share the same cgroup, and each container has its own limits configured, the order of container starts ultimately determines whose limits will be effectively applied. * If two or more containers share the same cgroup, and one of containers is paused/unpaused, all others are paused, too. * If cgroup.kill is used to forcefully kill the container, it will also kill other processes that are not part of this container but merely belong to the same cgroup. * When a systemd cgroup manager is used, this becomes even worse. Such as, stop (or even failed start) of any container results in stopTransientUnit command being sent to systemd, and so (depending on unit properties) other containers can receive SIGTERM, be killed after a timeout etc. * Many other bad scenarios are possible, as the implicit assumption of 1:1 container:cgroup mapping is broken. opencontainers/runc#3132 containers/crun#716 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent 0d6cc58 commit 104385d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

config-linux.md

+10
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,16 @@ Also known as cgroups, they are used to restrict resource usage for a container
171171
cgroups provide controls (through controllers) to restrict cpu, memory, IO, pids, network and RDMA resources for the container.
172172
For more information, see the [kernel cgroups documentation][cgroup-v1].
173173

174+
A runtime MAY, during a particular [container operation](runtime.md#operation),
175+
such as [create](runtime.md#create), [start](runtime.md#start), or
176+
[exec](runtime.md#exec), check if the container cgroup is fit for purpose,
177+
and MUST [generate an error](runtime.md#errors) if such a check fails.
178+
For example, a frozen cgroup or (for [create](runtime.md#create) operation)
179+
a non-empty cgroup. The reason for this is that accepting such configurations
180+
could cause container operation outcomes that users may not anticipate or
181+
understand, such as operation on one container inadvertently affecting other
182+
containers.
183+
174184
### <a name="configLinuxCgroupsPath" />Cgroups Path
175185

176186
**`cgroupsPath`** (string, OPTIONAL) path to the cgroups.

0 commit comments

Comments
 (0)