| 1259 | |
| 1260 | |
| 1261 | Future<Containerizer::LaunchResult> DockerContainerizerProcess::_launch( |
| 1262 | const ContainerID& containerId, |
| 1263 | const ContainerConfig& containerConfig) |
| 1264 | { |
| 1265 | if (!containers_.contains(containerId)) { |
| 1266 | return Failure("Container is already destroyed"); |
| 1267 | } |
| 1268 | |
| 1269 | Container* container = containers_.at(containerId); |
| 1270 | |
| 1271 | if (containerConfig.has_task_info() && flags.docker_mesos_image.isNone()) { |
| 1272 | // Launching task by forking a subprocess to run docker executor. |
| 1273 | // TODO(steveniemitz): We should call 'update' to set CPU/CFS/mem |
| 1274 | // quotas after 'launchExecutorProcess'. However, there is a race |
| 1275 | // where 'update' can be called before mesos-docker-executor |
| 1276 | // creates the Docker container for the task. See more details in |
| 1277 | // the comments of r33174. |
| 1278 | return container->launch = fetch(containerId) |
| 1279 | .then(defer(self(), [=]() { |
| 1280 | return pull(containerId); |
| 1281 | })) |
| 1282 | .then(defer(self(), [=]() { |
| 1283 | if (HookManager::hooksAvailable()) { |
| 1284 | HookManager::slavePostFetchHook( |
| 1285 | containerId, containerConfig.directory()); |
| 1286 | } |
| 1287 | |
| 1288 | return mountPersistentVolumes(containerId); |
| 1289 | })) |
| 1290 | .then(defer(self(), [=]() { |
| 1291 | return launchExecutorProcess(containerId); |
| 1292 | })) |
| 1293 | .then(defer(self(), [=](pid_t pid) { |
| 1294 | return reapExecutor(containerId, pid); |
| 1295 | })) |
| 1296 | .then([]() { |
| 1297 | return Containerizer::LaunchResult::SUCCESS; |
| 1298 | }); |
| 1299 | } |
| 1300 | |
| 1301 | string containerName = container->containerName; |
| 1302 | |
| 1303 | if (container->executorName().isSome()) { |
| 1304 | // Launch the container with the executor name as we expect the |
| 1305 | // executor will launch the docker container. |
| 1306 | containerName = container->executorName().get(); |
| 1307 | } |
| 1308 | |
| 1309 | // Launching task or executor by launching a separate docker |
| 1310 | // container to run the executor. |
| 1311 | // We need to do so for launching a task because as the slave is |
| 1312 | // running in a container (via docker_mesos_image flag) we want the |
| 1313 | // executor to keep running when the slave container dies. |
| 1314 | return container->launch = fetch(containerId) |
| 1315 | .then(defer(self(), [=]() { |
| 1316 | return pull(containerId); |
| 1317 | })) |
| 1318 | .then(defer(self(), [=]() { |
nothing calls this directly
no test coverage detected