X Tutup
Skip to content

Commit 39914db

Browse files
committed
runc exec: don't skip non-existing cgroups
The function used here, cgroups.EnterPid, silently skips non-existing paths, and it does not look like a good idea to do so for an existing container with already configured cgroups. Switch to cgroups.WriteCgroupProc which does not do that, so in case a cgroup does not exist, we'll get an error. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent 7d446c6 commit 39914db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libcontainer/process_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ func (p *setnsProcess) start() (retErr error) {
124124
if err := p.execSetns(); err != nil {
125125
return fmt.Errorf("error executing setns process: %w", err)
126126
}
127-
if len(p.cgroupPaths) > 0 {
128-
if err := cgroups.EnterPid(p.cgroupPaths, p.pid()); err != nil && !p.rootlessCgroups {
129-
// On cgroup v2 + nesting + domain controllers, EnterPid may fail with EBUSY.
127+
for _, path := range p.cgroupPaths {
128+
if err := cgroups.WriteCgroupProc(path, p.pid()); err != nil && !p.rootlessCgroups {
129+
// On cgroup v2 + nesting + domain controllers, WriteCgroupProc may fail with EBUSY.
130130
// https://github.com/opencontainers/runc/issues/2356#issuecomment-621277643
131131
// Try to join the cgroup of InitProcessPid.
132132
if cgroups.IsCgroup2UnifiedMode() {

0 commit comments

Comments
 (0)
X Tutup