Skip to content

Commit

Permalink
vc: make cgroup usage configurable if rootless
Browse files Browse the repository at this point in the history
rootless execution does not yet support cgroups, so if running
rootlessly skip the cgroup creation and deletion.

Fixes: 1877

Signed-off-by: Gabi Beyer <gabrielle.n.beyer@intel.com>
  • Loading branch information
Gabi Beyer authored and marcov committed Sep 23, 2019
1 parent 08bda33 commit 31199a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"

"github.com/kata-containers/runtime/pkg/rootless"
"github.com/kata-containers/runtime/virtcontainers/device/config"
"github.com/kata-containers/runtime/virtcontainers/device/manager"
"github.com/kata-containers/runtime/virtcontainers/store"
Expand Down Expand Up @@ -909,7 +910,7 @@ func (c *Container) create() (err error) {
}
c.process = *process

if !c.sandbox.config.SandboxCgroupOnly {
if !c.sandbox.config.SandboxCgroupOnly || !rootless.IsRootless() {
if err = c.cgroupsCreate(); err != nil {
return
}
Expand Down Expand Up @@ -940,7 +941,8 @@ func (c *Container) delete() error {
return err
}

if !c.sandbox.config.SandboxCgroupOnly {
// If running rootless, there are no cgroups to remove
if !c.sandbox.config.SandboxCgroupOnly || !rootless.IsRootless() {
if err := c.cgroupsDelete(); err != nil {
return err
}
Expand Down
7 changes: 5 additions & 2 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/vishvananda/netlink"

"github.com/kata-containers/agent/protocols/grpc"
"github.com/kata-containers/runtime/pkg/rootless"
"github.com/kata-containers/runtime/virtcontainers/device/api"
"github.com/kata-containers/runtime/virtcontainers/device/config"
"github.com/kata-containers/runtime/virtcontainers/device/drivers"
Expand Down Expand Up @@ -764,8 +765,10 @@ func (s *Sandbox) Delete() error {
}
}

if err := s.cgroupsDelete(); err != nil {
return err
if !rootless.IsRootless() {
if err := s.cgroupsDelete(); err != nil {
return err
}
}

globalSandboxList.removeSandbox(s.id)
Expand Down

0 comments on commit 31199a1

Please sign in to comment.