Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Currently the command executor will send either TASK_FAILED or TASK_FINISHED as a result of a killTask.
The fix is non-trivial since it requires sharing some state with the waiter thread:
static void waiter(pid_t pid, const TaskID& taskId, ExecutorDriver* driver)
{
int status;
while (wait(&status) != pid || WIFSTOPPED(status));
CHECK(WIFEXITED(status) || WIFSIGNALED(status));
std::cout << "Waited on process " << pid
<< ", returned status " << status << std::endl;
TaskStatus taskStatus;
taskStatus.mutable_task_id()->MergeFrom(taskId);
// THIS BIT NEEDS TO KNOW WHETHER THE TASK WAS KILLED!
if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
else
{ taskStatus.set_state(TASK_FAILED); } Try<string> message = WIFEXITED(status)
? strings::format("Command exited with status %d", WEXITSTATUS(status))
: strings::format("Command terminated with signal '%s'",
strsignal(WTERMSIG(status)));
if (message.isSome())
{ taskStatus.set_message(message.get()); }driver->sendStatusUpdate(taskStatus);
// A hack for now ... but we need to wait until for the status
// update to get sent to the slave before we shut ourselves down.
sleep(1);
driver->stop();
}