diff --git a/client/driver/exec_test.go b/client/driver/exec_test.go index 66771ca74..fde1cf09d 100644 --- a/client/driver/exec_test.go +++ b/client/driver/exec_test.go @@ -369,9 +369,10 @@ func TestExecDriver_Start_Kill_Wait(t *testing.T) { Name: "sleep", Config: map[string]interface{}{ "command": "/bin/sleep", - "args": []string{"45"}, + "args": []string{"100"}, }, - Resources: basicResources, + Resources: basicResources, + KillTimeout: 10 * time.Second, } driverCtx, execCtx := testDriverContexts(task) diff --git a/client/driver/executor/executor.go b/client/driver/executor/executor.go index 4384e1ce4..2de8e7bca 100644 --- a/client/driver/executor/executor.go +++ b/client/driver/executor/executor.go @@ -193,6 +193,12 @@ func (e *UniversalExecutor) wait() { e.exitState = &ProcessState{Pid: 0, ExitCode: exitCode, Time: time.Now()} } +var ( + // finishedErr is the error message received when trying to kill and already + // exited process. + finishedErr = "os: process already finished" +) + // Exit cleans up the alloc directory, destroys cgroups and kills the user // process func (e *UniversalExecutor) Exit() error { @@ -202,7 +208,7 @@ func (e *UniversalExecutor) Exit() error { if err != nil { 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 { + } else if err := proc.Kill(); err != nil && err.Error() != finishedErr { merr.Errors = append(merr.Errors, fmt.Errorf("can't kill process with pid: %v, err: %v", e.cmd.Process.Pid, err)) }