Fixed the kill test

This commit is contained in:
Diptanu Choudhury 2016-02-04 12:40:48 -08:00
parent 6c9f33ed19
commit 83882eca3f
3 changed files with 13 additions and 4 deletions

View File

@ -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
}

View File

@ -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,
}

View File

@ -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 {