Skip to content

Commit

Permalink
ctr: allow specifying --runc-systemd-cgroup
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Nov 8, 2019
1 parent 7f5d900 commit 8f74de9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/ctr/commands/run/run_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ var platformRunFlags = []cli.Flag{
Name: "runc-binary",
Usage: "specify runc-compatible binary",
},
cli.BoolFlag{
Name: "runc-systemd-cgroup",
Usage: "start runc with systemd cgroup manager",
},
}

// NewContainer creates a new container
Expand Down Expand Up @@ -181,6 +185,17 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
return nil, errors.New("specifying runc-binary is only supported for \"io.containerd.runc.v2\" runtime")
}
}
if context.Bool("runc-systemd-cgroup") {
if context.String("runtime") == "io.containerd.runc.v2" {
if context.String("cgroup") == "" {
// runc maps "machine.slice:foo:deadbeef" to "/machine.slice/foo-deadbeef.scope"
return nil, errors.New("option --runc-systemd-cgroup requires --cgroup to be set, e.g. \"machine.slice:foo:deadbeef\"")
}
runtimeOpts.SystemdCgroup = true
} else {
return nil, errors.New("specifying runc-systemd-cgroup is only supported for \"io.containerd.runc.v2\" runtime")
}
}
cOpts = append(cOpts, containerd.WithRuntime(context.String("runtime"), runtimeOpts))

opts = append(opts, oci.WithAnnotations(commands.LabelArgs(context.StringSlice("label"))))
Expand Down

0 comments on commit 8f74de9

Please sign in to comment.