diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2018-06-01 13:13:48 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-06-15 14:53:18 +0000 |
commit | 399c3a5e4bba2cbdab70af712b3ed75b48f4a761 (patch) | |
tree | 05a4cf585f2178c47fa5ea9458aa835d8bedf3f7 /libpod/oci.go | |
parent | ed0261176b2bd9ccd9a6cbf77727429429b8fedc (diff) | |
download | podman-399c3a5e4bba2cbdab70af712b3ed75b48f4a761.tar.gz podman-399c3a5e4bba2cbdab70af712b3ed75b48f4a761.tar.bz2 podman-399c3a5e4bba2cbdab70af712b3ed75b48f4a761.zip |
oci: do not set the cgroup path in Rootless mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #871
Approved by: mheon
Diffstat (limited to 'libpod/oci.go')
-rw-r--r-- | libpod/oci.go | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/libpod/oci.go b/libpod/oci.go index db0fd0d16..95bebdd88 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -349,23 +349,25 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string) (er childStartPipe.Close() // Move conmon to specified cgroup - if r.cgroupManager == SystemdCgroupsManager { - unitName := createUnitName("libpod-conmon", ctr.ID()) + if os.Getuid() == 0 { + if r.cgroupManager == SystemdCgroupsManager { + 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 { - logrus.Warnf("Failed to add conmon to systemd sandbox cgroup: %v", err) - } - } else { - cgroupPath := filepath.Join(ctr.config.CgroupParent, fmt.Sprintf("libpod-%s", ctr.ID()), "conmon") - control, err := cgroups.New(cgroups.V1, cgroups.StaticPath(cgroupPath), &spec.LinuxResources{}) - if err != nil { - logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) + logrus.Infof("Running conmon under slice %s and unitName %s", cgroupParent, unitName) + if err = utils.RunUnderSystemdScope(cmd.Process.Pid, cgroupParent, unitName); err != nil { + logrus.Warnf("Failed to add conmon to systemd sandbox cgroup: %v", err) + } } else { - // we need to remove this defer and delete the cgroup once conmon exits - // maybe need a conmon monitor? - if err := control.Add(cgroups.Process{Pid: cmd.Process.Pid}); err != nil { + cgroupPath := filepath.Join(ctr.config.CgroupParent, fmt.Sprintf("libpod-%s", ctr.ID()), "conmon") + control, err := cgroups.New(cgroups.V1, cgroups.StaticPath(cgroupPath), &spec.LinuxResources{}) + if err != nil { logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) + } else { + // we need to remove this defer and delete the cgroup once conmon exits + // maybe need a conmon monitor? + if err := control.Add(cgroups.Process{Pid: cmd.Process.Pid}); err != nil { + logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) + } } } } |