| 10801 | |
| 10802 | |
| 10803 | void Master::_removeSlave( |
| 10804 | Slave* slave, |
| 10805 | const Future<bool>& registrarResult, |
| 10806 | const string& removalCause, |
| 10807 | Option<Counter> reason) |
| 10808 | { |
| 10809 | CHECK_NOTNULL(slave); |
| 10810 | CHECK(slaves.removing.contains(slave->info.id())); |
| 10811 | slaves.removing.erase(slave->info.id()); |
| 10812 | |
| 10813 | CHECK(!registrarResult.isDiscarded()); |
| 10814 | |
| 10815 | if (registrarResult.isFailed()) { |
| 10816 | LOG(FATAL) << "Failed to remove agent " << *slave |
| 10817 | << " from the registrar: " << registrarResult.failure(); |
| 10818 | } |
| 10819 | |
| 10820 | // Should not happen: the master will only try to remove agents that |
| 10821 | // are currently admitted. |
| 10822 | CHECK(registrarResult.get()) |
| 10823 | << "Agent " << *slave |
| 10824 | << "already removed from the registrar"; |
| 10825 | |
| 10826 | LOG(INFO) << "Removed agent " << *slave << ": " << removalCause; |
| 10827 | |
| 10828 | ++metrics->slave_removals; |
| 10829 | if (reason.isSome()) { |
| 10830 | ++utils::copy(reason.get()); // Remove const. |
| 10831 | } |
| 10832 | |
| 10833 | // We want to remove the slave first, to avoid the allocator |
| 10834 | // re-allocating the recovered resources. |
| 10835 | allocator->removeSlave(slave->id); |
| 10836 | |
| 10837 | // Transition the tasks to lost and remove them. |
| 10838 | foreachkey (const FrameworkID& frameworkId, utils::copy(slave->tasks)) { |
| 10839 | Framework* framework = getFramework(frameworkId); |
| 10840 | CHECK(framework != nullptr) |
| 10841 | << "Framework " << frameworkId << " not found while removing agent " |
| 10842 | << *slave << "; agent tasks: " << slave->tasks; |
| 10843 | |
| 10844 | foreachvalue (Task* task, utils::copy(slave->tasks.at(frameworkId))) { |
| 10845 | // TODO(bmahler): Differentiate between agent removal reasons |
| 10846 | // (e.g. unhealthy vs. unregistered for maintenance). |
| 10847 | const StatusUpdate& update = protobuf::createStatusUpdate( |
| 10848 | task->framework_id(), |
| 10849 | task->slave_id(), |
| 10850 | task->task_id(), |
| 10851 | TASK_LOST, |
| 10852 | TaskStatus::SOURCE_MASTER, |
| 10853 | None(), |
| 10854 | "Agent " + slave->info.hostname() + " removed: " + removalCause, |
| 10855 | TaskStatus::REASON_SLAVE_REMOVED, |
| 10856 | (task->has_executor_id() ? |
| 10857 | Option<ExecutorID>(task->executor_id()) : None())); |
| 10858 | |
| 10859 | updateTask(task, update); |
| 10860 | removeTask(task); |
nothing calls this directly
no test coverage detected