Putting the plugin in the same cgroup as the user process

This commit is contained in:
Diptanu Choudhury
2016-02-05 00:11:09 -08:00
parent 49226c4a9c
commit ab493c2fb3
3 changed files with 20 additions and 8 deletions

View File

@@ -50,18 +50,21 @@ func (e *UniversalExecutor) configureIsolation() error {
}
// applyLimits puts a process in a pre-configured cgroup
func (e *UniversalExecutor) applyLimits() error {
func (e *UniversalExecutor) applyLimits(pid int) error {
if !e.ctx.ResourceLimits {
return nil
}
// Entering the process in the cgroup
manager := e.getCgroupManager(e.groups)
if err := manager.Apply(e.cmd.Process.Pid); err != nil {
if err := manager.Apply(pid); err != nil {
e.logger.Printf("[ERROR] unable to join cgroup: %v", err)
if err := e.Exit(); err != nil {
e.logger.Printf("[ERROR] unable to kill process: %v", err)
}
return err
}
return nil
}