From f4b32ae5fc8633c7e86e30a96e51c9f0aa617c2b Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Fri, 5 Feb 2016 13:16:29 -0800 Subject: [PATCH] Entering the plugin pid into the cgroup after creating it --- client/driver/executor/executor.go | 3 --- client/driver/executor/executor_linux.go | 9 +++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/driver/executor/executor.go b/client/driver/executor/executor.go index 136e2208d..fdafc3c05 100644 --- a/client/driver/executor/executor.go +++ b/client/driver/executor/executor.go @@ -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 { diff --git a/client/driver/executor/executor_linux.go b/client/driver/executor/executor_linux.go index 9c653eade..c95db04d0 100644 --- a/client/driver/executor/executor_linux.go +++ b/client/driver/executor/executor_linux.go @@ -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 }