Entering the plugin pid into the cgroup after creating it

This commit is contained in:
Diptanu Choudhury 2016-02-05 13:16:29 -08:00
parent 2871dfce26
commit f4b32ae5fc
2 changed files with 9 additions and 3 deletions

View file

@ -94,9 +94,6 @@ func (e *UniversalExecutor) LaunchCmd(command *ExecCommand, ctx *ExecutorContext
return nil, err
}
// entering the plugin process in cgroup
e.applyLimits(os.Getpid())
// setting the user of the process
if e.ctx.UnprivilegedUser {
if err := e.runAs("nobody"); err != nil {

View file

@ -45,6 +45,15 @@ func (e *UniversalExecutor) configureIsolation() error {
if err := e.configureCgroups(e.ctx.TaskResources); err != nil {
return fmt.Errorf("error creating cgroups: %v", err)
}
if err := e.applyLimits(os.Getpid()); err != nil {
if er := e.destroyCgroup(); er != nil {
e.logger.Printf("[ERROR] error destroying cgroup: %v", er)
}
if er := e.removeChrootMounts(); er != nil {
e.logger.Printf("[ERROR] error removing chroot: %v", er)
}
return fmt.Errorf("error entering the plugin process in the cgroup: %v:", err)
}
}
return nil
}