Skip to content

Commit 07e35a7

Browse files
author
Mrunal Patel
authored
Merge pull request #2600 from kolyshkin/libct-int-wut
libcontainer/integration: fix cgroupv1 + systemd tests
2 parents 10e5ab7 + f0fdde7 commit 07e35a7

File tree

6 files changed

+141
-132
lines changed

6 files changed

+141
-132
lines changed

libcontainer/cgroups/systemd/v1.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func (m *legacyManager) joinCgroups(pid int) error {
267267
}
268268

269269
func getSubsystemPath(c *configs.Cgroup, subsystem string) (string, error) {
270-
mountpoint, err := cgroups.FindCgroupMountpoint(c.Path, subsystem)
270+
mountpoint, err := cgroups.FindCgroupMountpoint("", subsystem)
271271
if err != nil {
272272
return "", err
273273
}
@@ -406,7 +406,10 @@ func (m *legacyManager) Set(container *configs.Config) error {
406406

407407
func enableKmem(c *configs.Cgroup) error {
408408
path, err := getSubsystemPath(c, "memory")
409-
if err != nil && !cgroups.IsNotFound(err) {
409+
if err != nil {
410+
if cgroups.IsNotFound(err) {
411+
return nil
412+
}
410413
return err
411414
}
412415

libcontainer/integration/checkpoint_test.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import (
1111
"testing"
1212

1313
"github.com/opencontainers/runc/libcontainer"
14-
"github.com/opencontainers/runc/libcontainer/configs"
15-
16-
"golang.org/x/sys/unix"
1714
)
1815

1916
func showFile(t *testing.T, fname string) error {
@@ -76,20 +73,10 @@ func testCheckpoint(t *testing.T, userns bool) {
7673
}
7774
defer remove(rootfs)
7875

79-
config := newTemplateConfig(rootfs)
80-
81-
if userns {
82-
config.UidMappings = []configs.IDMap{{HostID: 0, ContainerID: 0, Size: 1000}}
83-
config.GidMappings = []configs.IDMap{{HostID: 0, ContainerID: 0, Size: 1000}}
84-
config.Namespaces = append(config.Namespaces, configs.Namespace{Type: configs.NEWUSER})
85-
} else {
86-
config.Mounts = append(config.Mounts, &configs.Mount{
87-
Destination: "/sys/fs/cgroup",
88-
Device: "cgroup",
89-
Flags: defaultMountFlags | unix.MS_RDONLY,
90-
})
91-
}
92-
76+
config := newTemplateConfig(&tParam{
77+
rootfs: rootfs,
78+
userns: userns,
79+
})
9380
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
9481

9582
if err != nil {

0 commit comments

Comments
 (0)