summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/libpodruntime/runtime.go5
-rw-r--r--cmd/podman/main.go4
-rw-r--r--docs/podman.1.md3
-rw-r--r--libpod/container_internal.go4
-rw-r--r--libpod/oci.go2
-rw-r--r--libpod/options.go5
-rw-r--r--libpod/runtime.go2
7 files changed, 21 insertions, 4 deletions
diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go
index d1657325d..ea626ed8e 100644
--- a/cmd/podman/libpodruntime/runtime.go
+++ b/cmd/podman/libpodruntime/runtime.go
@@ -42,7 +42,10 @@ func GetRuntimeWithStorageOpts(c *cli.Context, storageOpts *storage.StoreOptions
options = append(options, libpod.WithConmonPath(c.GlobalString("conmon")))
}
- // TODO flag to set CGroup manager?
+ if c.GlobalIsSet("cgroup-manager") {
+ options = append(options, libpod.WithCgroupManager(c.GlobalString("cgroup-manager")))
+ }
+
// TODO flag to set libpod static dir?
// TODO flag to set libpod tmp dir?
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index aefde3b93..c928037e3 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -109,6 +109,10 @@ func main() {
}
app.Flags = []cli.Flag{
cli.StringFlag{
+ Name: "cgroup-manager",
+ Usage: "cgroup manager to use (cgroupfs or systemd, default cgroupfs)",
+ },
+ cli.StringFlag{
Name: "cni-config-dir",
Usage: "path of the configuration directory for CNI networks",
},
diff --git a/docs/podman.1.md b/docs/podman.1.md
index 3e0c59232..bf9b19c0c 100644
--- a/docs/podman.1.md
+++ b/docs/podman.1.md
@@ -23,6 +23,9 @@ has the capability to debug pods/images created by crio.
**--help, -h**
Print usage statement
+**--cgroup-manager**
+ CGroup manager to use for container cgroups. Supported values are cgroupfs (default) or systemd. Setting this flag can cause certain commands to break when called on containers created by the other CGroup manager type.
+
**--config value, -c**=**"config.file"**
Path of a config file detailing container server configuration options
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 1098dc66c..816e7bd31 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1133,7 +1133,9 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
// When runc is set to use Systemd as a cgroup manager, it
// expects cgroups to be passed as follows:
// slice:prefix:name
- g.SetLinuxCgroupsPath(path.Base(c.config.CgroupParent) + ":" + "libpod" + ":" + c.ID())
+ systemdCgroups := fmt.Sprintf("%s:libpod:%s", path.Base(c.config.CgroupParent), c.ID())
+ logrus.Debugf("Setting CGroups for container %s to %s", c.ID(), systemdCgroups)
+ g.SetLinuxCgroupsPath(systemdCgroups)
} else {
cgroupPath, err := c.CGroupPath()
if err != nil {
diff --git a/libpod/oci.go b/libpod/oci.go
index e1df807cd..3b24f2c23 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -321,7 +321,7 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string) (er
// Move conmon to specified cgroup
if r.cgroupManager == SystemdCgroupsManager {
- unitName := createUnitName("libpod", ctr.ID())
+ unitName := createUnitName("libpod-conmon", ctr.ID())
logrus.Infof("Running conmon under slice %s and unitName %s", cgroupParent, unitName)
if err = utils.RunUnderSystemdScope(cmd.Process.Pid, cgroupParent, unitName); err != nil {
diff --git a/libpod/options.go b/libpod/options.go
index 2b3ad2eb4..90b376668 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -152,6 +152,11 @@ func WithCgroupManager(manager string) RuntimeOption {
return ErrRuntimeFinalized
}
+ if manager != CgroupfsCgroupsManager && manager != SystemdCgroupsManager {
+ return errors.Wrapf(ErrInvalidArg, "CGroup manager must be one of %s and %s",
+ CgroupfsCgroupsManager, SystemdCgroupsManager)
+ }
+
rt.config.CgroupManager = manager
return nil
diff --git a/libpod/runtime.go b/libpod/runtime.go
index dde81a59d..bf484429e 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -158,7 +158,7 @@ var (
ConmonEnvVars: []string{
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
},
- CgroupManager: "cgroupfs",
+ CgroupManager: CgroupfsCgroupsManager,
HooksDir: hooks.DefaultHooksDir,
StaticDir: filepath.Join(storage.DefaultStoreOptions.GraphRoot, "libpod"),
TmpDir: "/var/run/libpod",