From a2faaa131711e5028ded2487a6d63c23bb54dfe6 Mon Sep 17 00:00:00 2001 From: Jay Kamat Date: Tue, 31 Jul 2018 19:42:49 -0700 Subject: [PATCH] Fix duplicate entries and missing entries in getCgroupMountsHelper Signed-off-by: Jay Kamat --- libcontainer/cgroups/utils.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libcontainer/cgroups/utils.go b/libcontainer/cgroups/utils.go index b7ff73f3..1a4c3e67 100644 --- a/libcontainer/cgroups/utils.go +++ b/libcontainer/cgroups/utils.go @@ -155,14 +155,16 @@ func getCgroupMountsHelper(ss map[string]bool, mi io.Reader, all bool) ([]Mount, if !known || (!all && seen) { continue } + ss[opt] = true if strings.HasPrefix(opt, cgroupNamePrefix) { opt = opt[len(cgroupNamePrefix):] } m.Subsystems = append(m.Subsystems, opt) - ss[opt] = true numFound++ } - res = append(res, m) + if len(m.Subsystems) > 0 || all { + res = append(res, m) + } } if err := scanner.Err(); err != nil { return nil, err