| 6956 | |
| 6957 | |
| 6958 | void Slave::executorLaunched( |
| 6959 | const FrameworkID& frameworkId, |
| 6960 | const ExecutorID& executorId, |
| 6961 | const ContainerID& containerId, |
| 6962 | const Future<Containerizer::LaunchResult>& future) |
| 6963 | { |
| 6964 | // Set up callback for executor termination. Note that we do this |
| 6965 | // regardless of whether or not we have successfully launched the |
| 6966 | // executor because even if we failed to launch the executor the |
| 6967 | // result of calling 'wait' will make sure everything gets properly |
| 6968 | // cleaned up. Note that we do this here instead of where we do |
| 6969 | // Containerizer::launch because we want to guarantee the contract |
| 6970 | // with the Containerizer that we won't call 'wait' until after the |
| 6971 | // launch has completed. |
| 6972 | containerizer->wait(containerId) |
| 6973 | .onAny(defer(self(), |
| 6974 | &Self::executorTerminated, |
| 6975 | frameworkId, |
| 6976 | executorId, |
| 6977 | lambda::_1)); |
| 6978 | |
| 6979 | if (!future.isReady()) { |
| 6980 | LOG(ERROR) << "Container '" << containerId |
| 6981 | << "' for executor '" << executorId |
| 6982 | << "' of framework " << frameworkId |
| 6983 | << " failed to start: " |
| 6984 | << (future.isFailed() ? future.failure() : "future discarded"); |
| 6985 | |
| 6986 | ++metrics.container_launch_errors; |
| 6987 | |
| 6988 | containerizer->destroy(containerId); |
| 6989 | |
| 6990 | Executor* executor = getExecutor(frameworkId, executorId); |
| 6991 | if (executor != nullptr) { |
| 6992 | ContainerTermination termination; |
| 6993 | termination.set_state(TASK_FAILED); |
| 6994 | termination.set_reason(TaskStatus::REASON_CONTAINER_LAUNCH_FAILED); |
| 6995 | termination.set_message( |
| 6996 | "Failed to launch container: " + |
| 6997 | (future.isFailed() ? future.failure() : "discarded")); |
| 6998 | |
| 6999 | executor->pendingTermination = termination; |
| 7000 | |
| 7001 | // TODO(jieyu): Set executor->state to be TERMINATING. |
| 7002 | } |
| 7003 | |
| 7004 | return; |
| 7005 | } else if (future.get() == Containerizer::LaunchResult::NOT_SUPPORTED) { |
| 7006 | LOG(ERROR) << "Container '" << containerId |
| 7007 | << "' for executor '" << executorId |
| 7008 | << "' of framework " << frameworkId |
| 7009 | << " failed to start: None of the enabled containerizers (" |
| 7010 | << flags.containerizers << ") could create a container for the " |
| 7011 | << "provided TaskInfo/ExecutorInfo message"; |
| 7012 | |
| 7013 | ++metrics.container_launch_errors; |
| 7014 | return; |
| 7015 | } else if (future.get() == Containerizer::LaunchResult::ALREADY_LAUNCHED) { |