From 488cd7e24eb73bb398fd75979d5206b4a3a3b9a0 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Fri, 2 Aug 2019 10:07:41 +0800 Subject: [PATCH] Check if driver handle is nil before execing Defend against tr.getDriverHandle being nil. Exec handler checks if task is running, but it may be stopped between check and driver handler fetching. --- client/allocrunner/taskrunner/task_runner.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/allocrunner/taskrunner/task_runner.go b/client/allocrunner/taskrunner/task_runner.go index e56bb7b3d4d1..5b2ea77b7e74 100644 --- a/client/allocrunner/taskrunner/task_runner.go +++ b/client/allocrunner/taskrunner/task_runner.go @@ -1347,7 +1347,12 @@ func appendTaskEvent(state *structs.TaskState, event *structs.TaskEvent, capacit } func (tr *TaskRunner) TaskExecHandler() drivermanager.TaskExecHandler { - return tr.getDriverHandle().ExecStreaming + // Check it is running + handle := tr.getDriverHandle() + if handle == nil { + return nil + } + return handle.ExecStreaming } func (tr *TaskRunner) DriverCapabilities() (*drivers.Capabilities, error) {