Skip to content

Commit

Permalink
Fix bug in cgroup config introduced by earlier commit.
Browse files Browse the repository at this point in the history
Commit a6023ce introduced a bug that was causing sysbox-runc
to not setup the continer's cgroups properly, specifically
the softlinks under /sys/fs/cgroup such as:

drwxr-xr-x 3 root root  0 May 13 20:46 blkio
lrwxrwxrwx 1 root root 11 May 13 20:46 cpu -> cpu,cpuacct
drwxr-xr-x 3 root root  0 May 13 20:46 cpu,cpuacct
lrwxrwxrwx 1 root root 11 May 13 20:46 cpuacct -> cpu,cpuacct

(i.e., the softlinks were missing inside the sysbox
container due to a bug in that commit).

This change fixes this.

Signed-off-by: Cesar Talledo <ctalledo@nestybox.com>
  • Loading branch information
ctalledo committed May 14, 2022
1 parent f67706c commit d91c42c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ func mountCgroupV1(m *configs.Mount, enableCgroupns bool, config *configs.Config
if err := mountToRootfs(tmpfs, config, enableCgroupns, pipe); err != nil {
return err
}

for _, b := range binds {
if enableCgroupns {

Expand Down Expand Up @@ -287,7 +288,11 @@ func mountCgroupV1(m *configs.Mount, enableCgroupns bool, config *configs.Config
// symlink(2) is very dumb, it will just shove the path into
// the link and doesn't do any checks or relative path
// conversion. Also, don't error out if the cgroup already exists.
if err := os.Symlink(mc, filepath.Join(m.Destination, ss)); err != nil && !os.IsExist(err) {
dest, err := securejoin.SecureJoin(".", filepath.Join(m.Destination, ss))
if err != nil {
return err
}
if err := os.Symlink(mc, dest); err != nil && !os.IsExist(err) {
return err
}
}
Expand Down

0 comments on commit d91c42c

Please sign in to comment.