Serialize Containerizer::launch,wait invocations. Review: https://reviews.apache.org/r/23463
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6ddca900 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6ddca900 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6ddca900 Branch: refs/heads/master Commit: 6ddca900a60a422c2bcba3015e304bf768ea3663 Parents: 8952b59 Author: Benjamin Hindman <[email protected]> Authored: Wed Jul 9 11:02:10 2014 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Mon Aug 4 09:15:50 2014 -0700 ---------------------------------------------------------------------- src/slave/slave.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/6ddca900/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index 8e40c5b..b4a5a45 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -2420,6 +2420,21 @@ void Slave::executorLaunched( const ContainerID& containerId, const Future<Nothing>& future) { + // Set up callback for executor termination. Note that we do this + // regardless of whether or not we have successfully launched the + // executor because even if we failed to launch the executor the + // result of calling 'wait' will make sure everything gets properly + // cleaned up. Note that we do this here instead of where we do + // Containerizer::launch because we want to guarantee the contract + // with the Containerizer that we won't call 'wait' until after the + // launch has completed. + containerizer->wait(containerId) + .onAny(defer(self(), + &Self::executorTerminated, + frameworkId, + executorId, + lambda::_1)); + if (!future.isReady()) { // The containerizer will clean up if the launch fails we'll just log this // and leave the executor registration to timeout. @@ -3516,14 +3531,6 @@ Executor* Framework::launchExecutor( containerId, lambda::_1)); - // Set up callback for executor termination. - slave->containerizer->wait(containerId) - .onAny(defer(slave, - &Slave::executorTerminated, - id, - executor->id, - lambda::_1)); - // Make sure the executor registers within the given timeout. delay(slave->flags.executor_registration_timeout, slave,
