Skip to content

Commit b790765

Browse files
author
Mrunal Patel
authored
Merge pull request #1009 from hqhq/fix_default_cgroup_parent
Fix default cgroup path
2 parents 795d5ce + 220e509 commit b790765

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

libcontainer/specconv/spec_linux.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"syscall"
1313
"time"
1414

15-
"github.com/opencontainers/runc/libcontainer/cgroups"
1615
"github.com/opencontainers/runc/libcontainer/configs"
1716
"github.com/opencontainers/runc/libcontainer/seccomp"
1817
libcontainerUtils "github.com/opencontainers/runc/libcontainer/utils"
@@ -253,10 +252,7 @@ func createLibcontainerMount(cwd string, m specs.Mount) *configs.Mount {
253252
}
254253

255254
func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*configs.Cgroup, error) {
256-
var (
257-
err error
258-
myCgroupPath string
259-
)
255+
var myCgroupPath string
260256

261257
c := &configs.Cgroup{
262258
Resources: &configs.Resources{},
@@ -287,11 +283,7 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
287283
}
288284
} else {
289285
if myCgroupPath == "" {
290-
myCgroupPath, err = cgroups.GetThisCgroupDir("devices")
291-
if err != nil {
292-
return nil, err
293-
}
294-
myCgroupPath = filepath.Join(myCgroupPath, name)
286+
c.Name = name
295287
}
296288
c.Path = myCgroupPath
297289
}

libcontainer/specconv/spec_linux_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package specconv
44

55
import (
6-
"strings"
76
"testing"
87

98
"github.com/opencontainers/runtime-spec/specs-go"
@@ -33,7 +32,7 @@ func TestLinuxCgroupsPathNotSpecified(t *testing.T) {
3332
t.Errorf("Couldn't create Cgroup config: %v", err)
3433
}
3534

36-
if !strings.HasSuffix(cgroup.Path, "/ContainerID") {
37-
t.Errorf("Wrong cgroupsPath, expected it to have suffix '%s' got '%s'", "/ContainerID", cgroup.Path)
35+
if cgroup.Path != "" {
36+
t.Errorf("Wrong cgroupsPath, expected it to be empty string, got '%s'", cgroup.Path)
3837
}
3938
}

0 commit comments

Comments
 (0)