From 83882eca3f6db6216f663a5283b6a71d8de340ab Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Thu, 4 Feb 2016 12:40:48 -0800 Subject: [PATCH] Fixed the kill test --- client/driver/exec.go | 3 +++ client/driver/exec_test.go | 2 +- client/driver/plugins/executor.go | 12 +++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/client/driver/exec.go b/client/driver/exec.go index fc0c49314..bff40f6a9 100644 --- a/client/driver/exec.go +++ b/client/driver/exec.go @@ -226,6 +226,9 @@ func (h *execHandle) Kill() error { case <-h.doneCh: return nil case <-time.After(h.killTimeout): + if h.pluginClient.Exited() { + return nil + } err := h.executor.Exit() return err } diff --git a/client/driver/exec_test.go b/client/driver/exec_test.go index a1ea5948e..16342870b 100644 --- a/client/driver/exec_test.go +++ b/client/driver/exec_test.go @@ -265,7 +265,7 @@ func TestExecDriver_Start_Kill_Wait(t *testing.T) { Name: "sleep", Config: map[string]interface{}{ "command": "/bin/sleep", - "args": []string{"1"}, + "args": []string{"10"}, }, Resources: basicResources, } diff --git a/client/driver/plugins/executor.go b/client/driver/plugins/executor.go index d4c572e32..0ad3d62aa 100644 --- a/client/driver/plugins/executor.go +++ b/client/driver/plugins/executor.go @@ -152,18 +152,24 @@ func (e *UniversalExecutor) Exit() error { if e.ctx.ResourceLimits { e.destroyCgroup() } - return proc.Kill() + if err = proc.Kill(); err != nil { + e.logger.Printf("[DEBUG] executor.exit error: %v", err) + } + return nil } func (e *UniversalExecutor) ShutDown() error { proc, err := os.FindProcess(e.cmd.Process.Pid) if err != nil { - return err + return fmt.Errorf("executor.shutdown error: %v", err) } if runtime.GOOS == "windows" { return proc.Kill() } - return proc.Signal(os.Interrupt) + if err = proc.Signal(os.Interrupt); err != nil { + return fmt.Errorf("executor.shutdown error: %v", err) + } + return nil } func (e *UniversalExecutor) configureTaskDir() error {