| 11251 | |
| 11252 | |
| 11253 | void Master::removeTask(Task* task, bool unreachable) |
| 11254 | { |
| 11255 | CHECK_NOTNULL(task); |
| 11256 | |
| 11257 | // The slave owns the Task object and cannot be nullptr. |
| 11258 | Slave* slave = slaves.registered.get(task->slave_id()); |
| 11259 | CHECK(slave != nullptr) << task->slave_id(); |
| 11260 | |
| 11261 | // Note that we explicitly convert from protobuf to `Resources` here |
| 11262 | // and then use the result below to avoid performance penalty for multiple |
| 11263 | // conversions and validations implied by conversion. |
| 11264 | // Conversion is safe, as resources have already passed validation. |
| 11265 | const Resources resources = task->resources(); |
| 11266 | |
| 11267 | // The invariant here is that the master will recover the resources |
| 11268 | // prior to removing terminal or unreachable tasks. If the task is |
| 11269 | // not terminal or unreachable, we must recover the resources here. |
| 11270 | // |
| 11271 | // TODO(bmahler): Currently, only `Master::finalize()` will call |
| 11272 | // `removeTask()` with a non-terminal task. Consider fixing this |
| 11273 | // and instead CHECKing here to simplify the logic. |
| 11274 | if (!protobuf::isTerminalState(task->state()) && |
| 11275 | task->state() != TASK_UNREACHABLE) { |
| 11276 | CHECK(!unreachable) << task->task_id(); |
| 11277 | |
| 11278 | // Note that we use `Resources` for output as it's faster than |
| 11279 | // logging raw protobuf data. |
| 11280 | LOG(WARNING) << "Removing task " << task->task_id() |
| 11281 | << " with resources " << resources |
| 11282 | << " of framework " << task->framework_id() |
| 11283 | << " on agent " << *slave |
| 11284 | << " in non-terminal state " << task->state(); |
| 11285 | |
| 11286 | allocator->recoverResources( |
| 11287 | task->framework_id(), |
| 11288 | task->slave_id(), |
| 11289 | resources, |
| 11290 | None(), |
| 11291 | true); |
| 11292 | } else { |
| 11293 | // Note that we use `Resources` for output as it's faster than |
| 11294 | // logging raw protobuf data. |
| 11295 | LOG(INFO) << "Removing task " << task->task_id() |
| 11296 | << " with resources " << resources |
| 11297 | << " of framework " << task->framework_id() |
| 11298 | << " on agent " << *slave; |
| 11299 | } |
| 11300 | |
| 11301 | if (unreachable) { |
| 11302 | slaves.unreachableTasks[slave->id][task->framework_id()] |
| 11303 | .push_back(task->task_id()); |
| 11304 | } |
| 11305 | |
| 11306 | // Remove from framework. |
| 11307 | Framework* framework = getFramework(task->framework_id()); |
| 11308 | if (framework != nullptr) { // A framework might not be reregistered yet. |
| 11309 | framework->removeTask(task, unreachable); |
| 11310 | } |
nothing calls this directly
no test coverage detected