Add checks for nil spec.Linux

Signed-off-by: Adam Thomason <ad@mthomason.net>
This commit is contained in:
Adam Thomason
2016-09-11 16:30:17 -07:00
parent fcbde0ce9f
commit 83cbdbd64c
2 changed files with 7 additions and 2 deletions
+4 -1
View File
@@ -258,7 +258,7 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
Resources: &configs.Resources{},
}
if spec.Linux.CgroupsPath != nil {
if spec.Linux != nil && spec.Linux.CgroupsPath != nil {
myCgroupPath = libcontainerUtils.CleanPath(*spec.Linux.CgroupsPath)
if useSystemdCgroup {
myCgroupPath = *spec.Linux.CgroupsPath
@@ -289,6 +289,9 @@ func createCgroupConfig(name string, useSystemdCgroup bool, spec *specs.Spec) (*
}
c.Resources.AllowedDevices = allowedDevices
if spec.Linux == nil {
return c, nil
}
r := spec.Linux.Resources
if r == nil {
return c, nil
+3 -1
View File
@@ -12,7 +12,9 @@ func TestLinuxCgroupsPathSpecified(t *testing.T) {
cgroupsPath := "/user/cgroups/path/id"
spec := &specs.Spec{}
spec.Linux.CgroupsPath = &cgroupsPath
spec.Linux = &specs.Linux{
CgroupsPath: &cgroupsPath,
}
cgroup, err := createCgroupConfig("ContainerID", false, spec)
if err != nil {