| 341 | } |
| 342 | |
| 343 | void killTask(KillTaskMessage&& killTaskMessage) |
| 344 | { |
| 345 | const TaskID taskId = killTaskMessage.task_id(); |
| 346 | |
| 347 | if (aborted.load()) { |
| 348 | VLOG(1) << "Ignoring kill task message for task " << taskId |
| 349 | << " because the driver is aborted!"; |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | // A kill task request is received when the driver is not connected. This |
| 354 | // can happen, for example, if `ExecutorRegisteredMessage` has not been |
| 355 | // delivered. We do not shutdown the driver because there might be other |
| 356 | // still running tasks and the executor might eventually reconnect, e.g., |
| 357 | // after the agent failover. We do not drop ignore the message because the |
| 358 | // actual executor may still want to react, e.g., commit suicide. |
| 359 | if (!connected) { |
| 360 | LOG(WARNING) << "Executor received kill task message for task " << taskId |
| 361 | << " while disconnected from the agent!"; |
| 362 | } |
| 363 | |
| 364 | VLOG(1) << "Executor asked to kill task '" << taskId << "'"; |
| 365 | |
| 366 | Stopwatch stopwatch; |
| 367 | if (FLAGS_v >= 1) { |
| 368 | stopwatch.start(); |
| 369 | } |
| 370 | |
| 371 | // If this is a Docker executor, call the `killTask()` overload which |
| 372 | // allows the kill policy to be overridden. |
| 373 | auto* dockerExecutor = dynamic_cast<docker::DockerExecutor*>(executor); |
| 374 | if (dockerExecutor) { |
| 375 | Option<KillPolicy> killPolicy = killTaskMessage.has_kill_policy() |
| 376 | ? killTaskMessage.kill_policy() |
| 377 | : Option<KillPolicy>::none(); |
| 378 | |
| 379 | dockerExecutor->killTask(driver, taskId, killPolicy); |
| 380 | } else { |
| 381 | executor->killTask(driver, taskId); |
| 382 | } |
| 383 | |
| 384 | VLOG(1) << "Executor::killTask took " << stopwatch.elapsed(); |
| 385 | } |
| 386 | |
| 387 | void statusUpdateAcknowledgement( |
| 388 | const SlaveID& slaveId, |