summaryrefslogtreecommitdiff
path: root/pkg/cgroups/systemd.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-14 17:30:09 +0200
committerGitHub <noreply@github.com>2019-08-14 17:30:09 +0200
commitf5dcb8011df1f8c7dd501e2ee1db9e069135fba9 (patch)
tree2f03cdd63a6a82601b9aa3dc974c17c8da2b4fe0 /pkg/cgroups/systemd.go
parent4823cf8fcc460f2d4f8707ff603234baff9d452a (diff)
parent9873901469bd5a4e435132cbb65aa6bacf798c2a (diff)
downloadpodman-f5dcb8011df1f8c7dd501e2ee1db9e069135fba9.tar.gz
podman-f5dcb8011df1f8c7dd501e2ee1db9e069135fba9.tar.bz2
podman-f5dcb8011df1f8c7dd501e2ee1db9e069135fba9.zip
Merge pull request #3810 from giuseppe/use-cgroups
pkg/cgroups: use DBUS session when rootless
Diffstat (limited to 'pkg/cgroups/systemd.go')
-rw-r--r--pkg/cgroups/systemd.go23
1 files changed, 5 insertions, 18 deletions
diff --git a/pkg/cgroups/systemd.go b/pkg/cgroups/systemd.go
index e72e456bc..b8e6db156 100644
--- a/pkg/cgroups/systemd.go
+++ b/pkg/cgroups/systemd.go
@@ -9,13 +9,7 @@ import (
"github.com/godbus/dbus"
)
-func systemdCreate(path string) error {
- c, err := systemdDbus.New()
- if err != nil {
- return err
- }
- defer c.Close()
-
+func systemdCreate(path string, c *systemdDbus.Conn) error {
slice, name := filepath.Split(path)
slice = strings.TrimSuffix(slice, "/")
@@ -43,7 +37,7 @@ func systemdCreate(path string) error {
}
ch := make(chan string)
- _, err = c.StartTransientUnit(name, "replace", properties, ch)
+ _, err := c.StartTransientUnit(name, "replace", properties, ch)
if err != nil {
lastError = err
continue
@@ -55,7 +49,7 @@ func systemdCreate(path string) error {
}
/*
- systemdDestroy is copied from containerd/cgroups/systemd.go file, that
+ systemdDestroyConn is copied from containerd/cgroups/systemd.go file, that
has the following license:
Copyright The containerd Authors.
@@ -72,18 +66,11 @@ func systemdCreate(path string) error {
See the License for the specific language governing permissions and
limitations under the License.
*/
-
-func systemdDestroy(path string) error {
- c, err := systemdDbus.New()
- if err != nil {
- return err
- }
- defer c.Close()
-
+func systemdDestroyConn(path string, c *systemdDbus.Conn) error {
name := filepath.Base(path)
ch := make(chan string)
- _, err = c.StopUnit(name, "replace", ch)
+ _, err := c.StopUnit(name, "replace", ch)
if err != nil {
return err
}