Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions libcontainer/cgroups/v1_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"sync"
"syscall"
Expand Down Expand Up @@ -165,7 +166,22 @@ func (m Mount) GetOwnCgroup(cgroups map[string]string) (string, error) {
func getCgroupMountsHelper(ss map[string]bool, mounts []*mountinfo.Info, all bool) ([]Mount, error) {
res := make([]Mount, 0, len(ss))
numFound := 0
parentIDs := make([]int, 0, len(mounts))
for _, mi := range mounts {
parentIDs = append(parentIDs, mi.Parent)
}

sort.Slice(parentIDs, func(i, j int) bool {
return parentIDs[i] < parentIDs[j]
})

for _, mi := range mounts {
// This mount is hidden by other mount
// at the same mountpoint, so skip it.
if sort.SearchInts(parentIDs, mi.ID) < len(parentIDs) {
continue
}

m := Mount{
Mountpoint: mi.Mountpoint,
Root: mi.Root,
Expand Down