mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Handle case that pid is dead in ForceStop
This commit is contained in:
@@ -120,7 +120,10 @@ func (e *BasicExecutor) ForceStop() error {
|
||||
return fmt.Errorf("Failed to find user processes %v: %v", e.spawn.UserPid, err)
|
||||
}
|
||||
|
||||
return proc.Kill()
|
||||
if err := proc.Kill(); err != nil && err.Error() != "os: process already finished" {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *BasicExecutor) Command() *exec.Cmd {
|
||||
|
||||
@@ -397,7 +397,7 @@ func (e *LinuxExecutor) destroyCgroup() error {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := process.Kill(); err != nil {
|
||||
if err := process.Kill(); err != nil && err.Error() != "os: process already finished" {
|
||||
multierror.Append(errs, fmt.Errorf("Failed to kill Pid %v: %v", pid, err))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -175,8 +176,9 @@ func TestTaskRunner_SaveRestoreState(t *testing.T) {
|
||||
defer tr2.Destroy()
|
||||
|
||||
// Destroy and wait
|
||||
time.Sleep(time.Duration(testutil.TestMultiplier()*5) * time.Second)
|
||||
if tr2.handle == nil {
|
||||
t.Fatalf("RestoreState() didn't open handle")
|
||||
}
|
||||
testutil.WaitForResult(func() (bool, error) {
|
||||
return tr2.handle != nil, fmt.Errorf("RestoreState() didn't open handle")
|
||||
}, func(err error) {
|
||||
t.Fatalf("err: %v", err)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user