From f2efece8100efb2a1e0e3b457b3c428439b483bb Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Tue, 9 Feb 2016 09:43:40 -0800 Subject: [PATCH 1/2] more time --- client/driver/exec_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/driver/exec_test.go b/client/driver/exec_test.go index de02f4959..85da6bfa5 100644 --- a/client/driver/exec_test.go +++ b/client/driver/exec_test.go @@ -322,9 +322,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) From 279f095a7d2b7811d5520ca84255da8b20b22c01 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Tue, 9 Feb 2016 10:00:42 -0800 Subject: [PATCH 2/2] Don't error killing exited process --- client/driver/executor/executor.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)) }