user1742188
user1742188

Reputation: 5103

Kill a task that is running in Mesos

While running some tasks in Mesos, some of my tasks will just freeze. I want to be able to kill these tasks. Is there any way to kill just one task in a Mesos framework? (I don't want to kill the entire framework)

Upvotes: 2

Views: 7058

Answers (2)

Lev Romanov
Lev Romanov

Reputation: 844

from http://mesos.apache.org/documentation/latest/scheduler-http-api/#kill

KILL

Sent by the scheduler to kill a specific task. If the scheduler has a custom executor, the kill is forwarded to the executor; it is up to the executor to kill the task and send a TASK_KILLED (or TASK_FAILED) update. If the task hasn’t yet been delivered to the executor when Mesos master or agent receives the kill request, a TASK_KILLED is generated and the task launch is not forwarded to the executor. Note that if the task belongs to a task group, killing of one task results in all tasks in the task group being killed. Mesos releases the resources for a task once it receives a terminal update for the task. If the task is unknown to the master, a TASK_LOST will be generated.

KILL Request (JSON):
POST /api/v1/scheduler  HTTP/1.1

Host: masterhost:5050
Content-Type: application/json
Mesos-Stream-Id: 130ae4e3-6b13-4ef4-baa9-9f2e85c3e9af

{
  "framework_id"    : {"value" : "12220-3440-12532-2345"},
  "type"            : "KILL",
  "kill"            : {
    "task_id"   :  {"value" : "12220-3440-12532-my-task"},
    "agent_id"  :  {"value" : "12220-3440-12532-S1233"}
  }
}

KILL Response:
HTTP/1.1 202 Accepted

Upvotes: 0

Chris.Cao
Chris.Cao

Reputation: 21

http://mesos.apache.org/documentation/latest/executor-http-api/

KILL The KILL event is sent whenever the scheduler needs to stop execution of a specific task. The executor is required to send a terminal update (e.g., TASK_FINISHED, TASK_KILLED or TASK_FAILED) back to the agent once it has stopped/killed the task. Mesos will mark the task resources as freed once the terminal update is received.

{
  "type" : "KILL",
  "kill" : {
    "task_id" : {"value" : "d40f3f3e-bbe3-44af-a230-4cb1eae72f67"}
   }
}

Upvotes: 2

Related Questions