Skip to content

Commit f6cbfb4

Browse files
committed
Change Load function in order to be more lenient on subsystems' checking
Currently when a cgroup path is not found under a subsystem's directory Load function will fail completely. This can be blocking when a subsystem is taking time to update its cgroups. This commit makes Load to by-pass any not-found subsystem returning a Cgroup with a list of the only-found subsystems. Signed-off-by: Chris Mark <[email protected]>
1 parent 965bb1d commit f6cbfb4

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

cgroup.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ func New(hierarchy Hierarchy, path Path, resources *specs.LinuxResources) (Cgrou
4848

4949
// Load will load an existing cgroup and allow it to be controlled
5050
func Load(hierarchy Hierarchy, path Path) (Cgroup, error) {
51+
var activeSubsystems []Subsystem
5152
subsystems, err := hierarchy()
5253
if err != nil {
5354
return nil, err
5455
}
55-
// check the the subsystems still exist
56+
// check that the subsystems still exist, and keep only those that actually exist
5657
for _, s := range pathers(subsystems) {
5758
p, err := path(s.Name())
5859
if err != nil {
@@ -63,14 +64,15 @@ func Load(hierarchy Hierarchy, path Path) (Cgroup, error) {
6364
}
6465
if _, err := os.Lstat(s.Path(p)); err != nil {
6566
if os.IsNotExist(err) {
66-
return nil, ErrCgroupDeleted
67+
continue
6768
}
6869
return nil, err
6970
}
71+
activeSubsystems = append(activeSubsystems, s)
7072
}
7173
return &cgroup{
7274
path: path,
73-
subsystems: subsystems,
75+
subsystems: activeSubsystems,
7476
}, nil
7577
}
7678

0 commit comments

Comments
 (0)