| 2534 | |
| 2535 | |
| 2536 | void DockerContainerizerProcess::_destroy( |
| 2537 | const ContainerID& containerId, |
| 2538 | bool killed) |
| 2539 | { |
| 2540 | CHECK(containers_.contains(containerId)); |
| 2541 | |
| 2542 | Container* container = containers_.at(containerId); |
| 2543 | |
| 2544 | CHECK(container->state == Container::DESTROYING); |
| 2545 | |
| 2546 | // Do a 'docker stop' which we'll then find out about in '_destroy' |
| 2547 | // after we've reaped either the container's root process (in the |
| 2548 | // event that we had just launched a container for an executor) or |
| 2549 | // the mesos-docker-executor (in the case we launched a container |
| 2550 | // for a task). |
| 2551 | LOG(INFO) << "Running docker stop on container " << containerId; |
| 2552 | |
| 2553 | if (killed) { |
| 2554 | // TODO(alexr): After the deprecation cycle (started in 1.0), update |
| 2555 | // this to omit the timeout. Graceful shutdown of the container is not |
| 2556 | // a containerizer responsibility; it is the responsibility of the agent |
| 2557 | // in co-operation with the executor. Once `destroy()` is called, the |
| 2558 | // container should be destroyed forcefully. |
| 2559 | // The `after` fallback should remain as a precaution against the docker |
| 2560 | // stop command hanging. |
| 2561 | docker->stop(container->containerName, flags.docker_stop_timeout) |
| 2562 | .after( |
| 2563 | flags.docker_stop_timeout + DOCKER_FORCE_KILL_TIMEOUT, |
| 2564 | defer(self(), &Self::destroyTimeout, containerId, lambda::_1)) |
| 2565 | .onAny(defer(self(), &Self::__destroy, containerId, killed, lambda::_1)); |
| 2566 | } else { |
| 2567 | __destroy(containerId, killed, Nothing()); |
| 2568 | } |
| 2569 | } |
| 2570 | |
| 2571 | |
| 2572 | void DockerContainerizerProcess::__destroy( |