From 9b2e117f684bd5620a4fb125eea6a714dced7970 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Mon, 8 Feb 2016 11:56:48 -0800 Subject: [PATCH] Making the plugin server return the same instance of executor rpc server --- client/driver/executor/executor.go | 12 +++++++----- client/driver/executor_plugin.go | 6 +++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/client/driver/executor/executor.go b/client/driver/executor/executor.go index 99d1c6fe2..65501c0db 100644 --- a/client/driver/executor/executor.go +++ b/client/driver/executor/executor.go @@ -192,10 +192,11 @@ func (e *UniversalExecutor) Exit() error { if e.cmd.Process != nil { proc, err := os.FindProcess(e.cmd.Process.Pid) if err != nil { - e.logger.Printf("[ERROR] can't find process with pid: %v, err: %v", e.cmd.Process.Pid, err) - } - if err := proc.Kill(); err != nil { - e.logger.Printf("[ERROR] can't kill process with pid: %v, err: %v", e.cmd.Process.Pid, err) + e.logger.Printf("[ERROR] executor: can't find process with pid: %v, err: %v", + e.cmd.Process.Pid, err) + } else if err := proc.Kill(); err != nil { + merr.Errors = append(merr.Errors, + fmt.Errorf("can't kill process with pid: %v, err: %v", e.cmd.Process.Pid, err)) } } @@ -230,11 +231,12 @@ func (e *UniversalExecutor) ShutDown() error { return nil } +// configureTaskDir sets the task dir in the executor func (e *UniversalExecutor) configureTaskDir() error { taskDir, ok := e.ctx.AllocDir.TaskDirs[e.ctx.TaskName] e.taskDir = taskDir if !ok { - return fmt.Errorf("Couldn't find task directory for task %v", e.ctx.TaskName) + return fmt.Errorf("couldn't find task directory for task %v", e.ctx.TaskName) } e.cmd.Dir = taskDir return nil diff --git a/client/driver/executor_plugin.go b/client/driver/executor_plugin.go index 57a95e326..1be91a3ce 100644 --- a/client/driver/executor_plugin.go +++ b/client/driver/executor_plugin.go @@ -106,10 +106,14 @@ func (e *ExecutorRPCServer) Exit(args interface{}, resp *interface{}) error { type ExecutorPlugin struct { logger *log.Logger + Impl *ExecutorRPCServer } func (p *ExecutorPlugin) Server(*plugin.MuxBroker) (interface{}, error) { - return &ExecutorRPCServer{Impl: executor.NewExecutor(p.logger)}, nil + if p.Impl == nil { + p.Impl = &ExecutorRPCServer{Impl: executor.NewExecutor(p.logger)} + } + return p.Impl, nil } func (p *ExecutorPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error) {