raw_exec: ensure executor is killed after task is stopped
This commit is contained in:
parent
7c61b47a6d
commit
1f4c26e19e
|
@ -292,6 +292,8 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {
|
|||
procState: drivers.TaskStateRunning,
|
||||
startedAt: taskState.StartedAt,
|
||||
exitResult: &drivers.ExitResult{},
|
||||
logger: d.logger,
|
||||
doneCh: make(chan struct{}),
|
||||
}
|
||||
|
||||
d.tasks.Set(taskState.TaskConfig.ID, h)
|
||||
|
@ -356,6 +358,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
|
|||
procState: drivers.TaskStateRunning,
|
||||
startedAt: time.Now().Round(time.Millisecond),
|
||||
logger: d.logger,
|
||||
doneCh: make(chan struct{}),
|
||||
}
|
||||
|
||||
driverState := TaskState{
|
||||
|
@ -426,6 +429,12 @@ func (d *Driver) StopTask(taskID string, timeout time.Duration, signal string) e
|
|||
return fmt.Errorf("executor Shutdown failed: %v", err)
|
||||
}
|
||||
|
||||
// Wait for handle to finish
|
||||
<-handle.doneCh
|
||||
|
||||
// Kill executor
|
||||
handle.pluginClient.Kill()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ func (d *Driver) recoverPre09Task(h *drivers.TaskHandle) error {
|
|||
procState: drivers.TaskStateRunning,
|
||||
startedAt: time.Now(),
|
||||
exitResult: &drivers.ExitResult{},
|
||||
logger: d.logger,
|
||||
doneCh: make(chan struct{}),
|
||||
}
|
||||
|
||||
d.tasks.Set(h.Config.ID, th)
|
||||
|
|
|
@ -26,6 +26,7 @@ type taskHandle struct {
|
|||
startedAt time.Time
|
||||
completedAt time.Time
|
||||
exitResult *drivers.ExitResult
|
||||
doneCh chan struct{}
|
||||
}
|
||||
|
||||
func (h *taskHandle) TaskStatus() *drivers.TaskStatus {
|
||||
|
@ -52,6 +53,7 @@ func (h *taskHandle) IsRunning() bool {
|
|||
}
|
||||
|
||||
func (h *taskHandle) run() {
|
||||
defer close(h.doneCh)
|
||||
h.stateLock.Lock()
|
||||
if h.exitResult == nil {
|
||||
h.exitResult = &drivers.ExitResult{}
|
||||
|
|
Loading…
Reference in a new issue