Add systemd cgroup support.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-09-26 06:44:30 +00:00
parent 86ee919013
commit cd57d063c5
7 changed files with 53 additions and 8 deletions

View File

@@ -22,6 +22,7 @@ import (
"strings"
"github.com/containerd/containerd"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/typeurl"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/golang/glog"
@@ -146,7 +147,11 @@ func (c *criContainerdService) RunPodSandbox(ctx context.Context, r *runtime.Run
containerd.WithSpec(spec, specOpts...),
containerd.WithContainerLabels(map[string]string{containerKindLabel: containerKindSandbox}),
containerd.WithContainerExtension(sandboxMetadataExtension, &sandbox.Metadata),
containerd.WithRuntime(defaultRuntime, nil)}
containerd.WithRuntime(
defaultRuntime,
&runcopts.RuncOptions{SystemdCgroup: c.config.SystemdCgroup},
),
}
container, err := c.client.NewContainer(ctx, id, opts...)
if err != nil {
return nil, fmt.Errorf("failed to create containerd container: %v", err)
@@ -258,7 +263,8 @@ func (c *criContainerdService) generateSandboxContainerSpec(id string, config *r
// Set cgroups parent.
if config.GetLinux().GetCgroupParent() != "" {
cgroupsPath := getCgroupsPath(config.GetLinux().GetCgroupParent(), id)
cgroupsPath := getCgroupsPath(config.GetLinux().GetCgroupParent(), id,
c.config.SystemdCgroup)
g.SetLinuxCgroupsPath(cgroupsPath)
}
// When cgroup parent is not set, containerd-shim will create container in a child cgroup