MCPcopy Create free account
hub / github.com/apache/mesos / kill

Method kill

src/master/master.cpp:5688–5762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5686
5687
5688void Master::kill(Framework* framework, const scheduler::Call::Kill& kill)
5689{
5690 CHECK_NOTNULL(framework);
5691
5692 const TaskID& taskId = kill.task_id();
5693 const Option<SlaveID> slaveId =
5694 kill.has_slave_id() ? Option<SlaveID>(kill.slave_id()) : None();
5695
5696 LOG(INFO) << "Processing KILL call for task '" << taskId << "'"
5697 << " of framework " << *framework;
5698
5699 ++metrics->messages_kill_task;
5700
5701 Task* task = framework->getTask(taskId);
5702 if (task == nullptr) {
5703 LOG(WARNING) << "Cannot kill task " << taskId
5704 << " of framework " << *framework
5705 << " because it is unknown; performing reconciliation";
5706
5707 scheduler::Call::Reconcile message;
5708 scheduler::Call::Reconcile::Task* t = message.add_tasks();
5709
5710 *t->mutable_task_id() = taskId;
5711
5712 if (slaveId.isSome()) {
5713 *t->mutable_slave_id() = slaveId.get();
5714 }
5715
5716 reconcile(framework, std::move(message));
5717 return;
5718 }
5719
5720 if (slaveId.isSome() && slaveId.get() != task->slave_id()) {
5721 LOG(WARNING) << "Cannot kill task " << taskId << " of agent "
5722 << slaveId.get() << " of framework " << *framework
5723 << " because it belongs to different agent "
5724 << task->slave_id();
5725
5726 // TODO(vinod): Return a "Bad Request" when using HTTP API.
5727 return;
5728 }
5729
5730 Slave* slave = slaves.registered.get(task->slave_id());
5731 CHECK(slave != nullptr) << "Unknown agent " << task->slave_id();
5732
5733 // We add the task to 'killedTasks' here because the slave
5734 // might be partitioned or disconnected but the master
5735 // doesn't know it yet.
5736 slave->killedTasks.put(framework->id(), taskId);
5737
5738 // NOTE: This task will be properly reconciled when the disconnected slave
5739 // reregisters with the master.
5740 // We send the KillTaskMessage even if we have already sent one, just in case
5741 // the previous one was dropped by the network but it didn't trigger a slave
5742 // re-registration (and hence reconciliation).
5743 if (slave->connected) {
5744 LOG(INFO) << "Telling agent " << *slave
5745 << " to kill task " << taskId

Callers 2

schedulerMethod · 0.45
receiveMethod · 0.45

Calls 8

NoneClass · 0.85
MergeFromMethod · 0.80
sendFunction · 0.50
getTaskMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45
putMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected