Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-380

Command Executor doesn't send TASK_KILLED for killed tasks.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.14.0
    • 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)

      { taskStatus.set_state(TASK_FINISHED); }

      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();
      }

      Attachments

        Activity

          People

            vinodkone Vinod Kone
            bmahler Benjamin Mahler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: