From edad8f866d29895cd9206655ab1d99dbabcf3a7c Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Mon, 19 Dec 2016 15:01:27 -0800 Subject: [PATCH] Add configuration for specifying cgroup manager Signed-off-by: Mrunal Patel --- cmd/server/config.go | 6 ++++++ cmd/server/main.go | 7 +++++++ server/config.go | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/cmd/server/config.go b/cmd/server/config.go index 0988976e..24db0c21 100644 --- a/cmd/server/config.go +++ b/cmd/server/config.go @@ -16,6 +16,7 @@ const ( pausePath = "/usr/libexec/ocid/pause" seccompProfilePath = "/etc/ocid/seccomp.json" apparmorProfileName = "ocid-default" + cgroupManager = "cgroupfs" ) var commentedConfigTemplate = template.Must(template.New("config").Parse(` @@ -69,6 +70,10 @@ seccomp_profile = "{{ .SeccompProfile }}" # default for the runtime. apparmor_profile = "{{ .ApparmorProfile }}" +# cgroup_manager is the cgroup management implementation to be used +# for the runtime. +cgroup_manager = "{{ .CgroupManager }}" + # The "ocid.image" table contains settings pertaining to the # management of OCI images. [ocid.image] @@ -102,6 +107,7 @@ func DefaultConfig() *server.Config { SELinux: selinux.SelinuxEnabled(), SeccompProfile: seccompProfilePath, ApparmorProfile: apparmorProfileName, + CgroupManager: cgroupManager, }, ImageConfig: server.ImageConfig{ Pause: pausePath, diff --git a/cmd/server/main.go b/cmd/server/main.go index 2f5a20dc..334dfecb 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -63,6 +63,9 @@ func mergeConfig(config *server.Config, ctx *cli.Context) error { if ctx.GlobalIsSet("apparmor-profile") { config.ApparmorProfile = ctx.GlobalString("apparmor-profile") } + if ctx.GlobalIsSet("cgroup-manager") { + config.CgroupManager = ctx.GlobalString("cgroup-manager") + } return nil } @@ -150,6 +153,10 @@ func main() { Name: "selinux", Usage: "enable selinux support", }, + cli.StringFlag{ + Name: "cgroup-manager", + Usage: "cgroup manager (cgroupfs or systemd)", + }, } // remove once https://github.com/urfave/cli/pull/544 lands diff --git a/server/config.go b/server/config.go index 75e93aa3..20bd1663 100644 --- a/server/config.go +++ b/server/config.go @@ -72,6 +72,10 @@ type RuntimeConfig struct { // ApparmorProfile is the apparmor profile name which is used as the // default for the runtime. ApparmorProfile string `toml:"apparmor_profile"` + + // CgroupManager is the manager implementation name which is used to + // handle cgroups for containers. + CgroupManager string `toml:"cgroup_manager"` } // ImageConfig represents the "ocid.image" TOML config table.