From 14473270d7af520dae006605ab798ad9db34f184 Mon Sep 17 00:00:00 2001 From: baude Date: Mon, 1 Oct 2018 12:10:46 -0500 Subject: Add ability for ubuntu to be tested unfortunately the papr CI system cannot test ubuntu as a VM; therefore, this PR still keeps travis. but it does include fixes that will be required for running on modern versions of ubuntu. Signed-off-by: baude --- libpod/util.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libpod/util.go') diff --git a/libpod/util.go b/libpod/util.go index 17325f6e4..3b51e4fcc 100644 --- a/libpod/util.go +++ b/libpod/util.go @@ -9,8 +9,10 @@ import ( "strings" "time" + "github.com/containerd/cgroups" "github.com/containers/image/signature" "github.com/containers/image/types" + "github.com/containers/libpod/pkg/util" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" ) @@ -160,3 +162,26 @@ func validPodNSOption(p *Pod, ctrPod string) error { } return nil } + +// GetV1CGroups gets the V1 cgroup subsystems and then "filters" +// out any subsystems that are provided by the caller. Passing nil +// for excludes will return the subsystems unfiltered. +//func GetV1CGroups(excludes []string) ([]cgroups.Subsystem, error) { +func GetV1CGroups(excludes []string) cgroups.Hierarchy { + return func() ([]cgroups.Subsystem, error) { + var filtered []cgroups.Subsystem + + subSystem, err := cgroups.V1() + if err != nil { + return nil, err + } + for _, s := range subSystem { + // If the name of the subsystem is not in the list of excludes, then + // add it as a keeper. + if !util.StringInSlice(string(s.Name()), excludes) { + filtered = append(filtered, s) + } + } + return filtered, nil + } +} -- cgit v1.2.3-54-g00ecf