Skip to content

Commit

Permalink
Change Load function in order to be more lenient on subsystems' checking
Browse files Browse the repository at this point in the history
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 <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark committed Nov 2, 2018
1 parent 965bb1d commit f6cbfb4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ func New(hierarchy Hierarchy, path Path, resources *specs.LinuxResources) (Cgrou

// Load will load an existing cgroup and allow it to be controlled
func Load(hierarchy Hierarchy, path Path) (Cgroup, error) {
var activeSubsystems []Subsystem
subsystems, err := hierarchy()
if err != nil {
return nil, err
}
// check the the subsystems still exist
// check that the subsystems still exist, and keep only those that actually exist
for _, s := range pathers(subsystems) {
p, err := path(s.Name())
if err != nil {
Expand All @@ -63,14 +64,15 @@ func Load(hierarchy Hierarchy, path Path) (Cgroup, error) {
}
if _, err := os.Lstat(s.Path(p)); err != nil {
if os.IsNotExist(err) {
return nil, ErrCgroupDeleted
continue
}
return nil, err
}
activeSubsystems = append(activeSubsystems, s)
}
return &cgroup{
path: path,
subsystems: subsystems,
subsystems: activeSubsystems,
}, nil
}

Expand Down

0 comments on commit f6cbfb4

Please sign in to comment.