Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
cgroups: fix failed to remove sandbox cgroup
Browse files Browse the repository at this point in the history
sandbox cgroup use V1NoConstraints, this only create memory subsystem,
but when delete, load parent cgroup always use `cgroups.V1`, so other
subsystem path can not be find, sandbox cgroup can not be deleted.

Fixes: #1263

Signed-off-by: Ace-Tang <[email protected]>
  • Loading branch information
Ace-Tang committed Feb 21, 2019
1 parent 1d79338 commit 454775f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions virtcontainers/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ func cgroupNoConstraintsPath(path string) string {
}

// return the parent cgroup for the given path
func parentCgroup(path string) (cgroups.Cgroup, error) {
func parentCgroup(hierarchy cgroups.Hierarchy, path string) (cgroups.Cgroup, error) {
// append '/' just in case CgroupsPath doesn't start with it
parent := filepath.Dir("/" + path)

parentCgroup, err := cgroupsLoadFunc(cgroups.V1,
parentCgroup, err := cgroupsLoadFunc(hierarchy,
cgroups.StaticPath(parent))
if err != nil {
return nil, fmt.Errorf("Could not load parent cgroup %v: %v", parent, err)
Expand Down Expand Up @@ -186,7 +186,7 @@ func (s *Sandbox) deleteCgroups() error {
}

// move running process here, that way cgroup can be removed
parent, err := parentCgroup(path)
parent, err := parentCgroup(V1NoConstraints, path)
if err != nil {
// parent cgroup doesn't exist, that means there are no process running
// and the no constraints cgroup was removed.
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ func (c *Container) deleteCgroups() error {
}

// move running process here, that way cgroup can be removed
parent, err := parentCgroup(c.state.CgroupPath)
parent, err := parentCgroup(cgroups.V1, c.state.CgroupPath)
if err != nil {
// parent cgroup doesn't exist, that means there are no process running
// and the container cgroup was removed.
Expand Down

0 comments on commit 454775f

Please sign in to comment.