Skip to content

Commit

Permalink
cgroupv2: enable controllers before setting resources in NewChild()
Browse files Browse the repository at this point in the history
Signed-off-by: Miao Wang <[email protected]>
  • Loading branch information
shankerwangmiao committed Jul 26, 2021
1 parent 2c11864 commit 2ca92c5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions v2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,23 @@ func (c *Manager) NewChild(name string, resources *Resources) (*Manager, error)
if err := os.MkdirAll(path, defaultDirPerm); err != nil {
return nil, err
}
m := Manager{
unifiedMountpoint: c.unifiedMountpoint,
path: path,
}
if resources != nil {
if err := m.ToggleControllers(resources.EnabledControllers(), Enable); err != nil {
// clean up cgroup dir on failure
os.Remove(path)
return nil, err
}
}
if err := setResources(path, resources); err != nil {
// clean up cgroup dir on failure
os.Remove(path)
return nil, err
}
return &Manager{
unifiedMountpoint: c.unifiedMountpoint,
path: path,
}, nil
return &m, nil
}

func (c *Manager) AddProc(pid uint64) error {
Expand Down

0 comments on commit 2ca92c5

Please sign in to comment.