You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/09/27 01:30:02 UTC
[1/7] mesos git commit: Updated the streaming function for
ContainerID to be nesting aware.
Repository: mesos
Updated Branches:
refs/heads/master 9ee31f619 -> ad73e8c7d
Updated the streaming function for ContainerID to be nesting aware.
We are using '.' as a separator. If we have a nested container "yyy"
under its parent container "xxx". Then, the streaming function will
print it out as "xxx.yyy".
Review: https://reviews.apache.org/r/51825/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c31887fe
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c31887fe
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c31887fe
Branch: refs/heads/master
Commit: c31887fe0351dc4e1ddf68205b2f5c5432a284d5
Parents: 9ee31f6
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 17:16:11 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 17:16:17 2016 -0700
----------------------------------------------------------------------
src/common/type_utils.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c31887fe/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index 9cb6274..8fde673 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -444,7 +444,9 @@ bool operator!=(const TaskStatus& left, const TaskStatus& right)
ostream& operator<<(ostream& stream, const ContainerID& containerId)
{
- return stream << containerId.value();
+ return containerId.has_parent()
+ ? stream << containerId.parent() << "." << containerId.value()
+ : stream << containerId.value();
}
[7/7] mesos git commit: Changed 'ExecutorInfo' to be optional in
ContainerState.
Posted by ji...@apache.org.
Changed 'ExecutorInfo' to be optional in ContainerState.
This is necessary for recovering nested containers, because a list of
'ContainerState' including recoverable top level containers and nested
containers will be passed to isolator::recover, but there is no way for
nested containers to carry the ExecutorInfo.
Review: https://reviews.apache.org/r/52233/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ad73e8c7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ad73e8c7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ad73e8c7
Branch: refs/heads/master
Commit: ad73e8c7d8a6f39b3fe4edb9c53a4aa1619c9d38
Parents: 837cbf7
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 17:32:37 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 18:29:48 2016 -0700
----------------------------------------------------------------------
include/mesos/slave/containerizer.proto | 12 ++++++++----
src/common/protobuf_utils.cpp | 9 +++++++--
src/common/protobuf_utils.hpp | 2 +-
3 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ad73e8c7/include/mesos/slave/containerizer.proto
----------------------------------------------------------------------
diff --git a/include/mesos/slave/containerizer.proto b/include/mesos/slave/containerizer.proto
index 238dbb6..86d1859 100644
--- a/include/mesos/slave/containerizer.proto
+++ b/include/mesos/slave/containerizer.proto
@@ -52,13 +52,17 @@ message ContainerLimitation {
* any dependency on RunState and in turn on internal protobufs.
*/
message ContainerState {
- required ExecutorInfo executor_info = 1;
+ // This field only exists for top level containers.
+ optional ExecutorInfo executor_info = 1;
- // Container id of the last executor run.
+ // The container Id.
required ContainerID container_id = 2;
- required uint64 pid = 3; // Executor pid.
- required string directory = 4; // Executor work directory.
+ // The pid of the init process in the container.
+ required uint64 pid = 3;
+
+ // The sandbox directory.
+ required string directory = 4;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/ad73e8c7/src/common/protobuf_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index 3ff37f4..1f08868 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -379,16 +379,21 @@ ContainerLimitation createContainerLimitation(
ContainerState createContainerState(
- const ExecutorInfo& executorInfo,
+ const Option<ExecutorInfo>& executorInfo,
const ContainerID& container_id,
pid_t pid,
const string& directory)
{
ContainerState state;
- state.mutable_executor_info()->CopyFrom(executorInfo);
+
+ if (executorInfo.isSome()) {
+ state.mutable_executor_info()->CopyFrom(executorInfo.get());
+ }
+
state.mutable_container_id()->CopyFrom(container_id);
state.set_pid(pid);
state.set_directory(directory);
+
return state;
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/ad73e8c7/src/common/protobuf_utils.hpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.hpp b/src/common/protobuf_utils.hpp
index c5e5a9a..0c6405f 100644
--- a/src/common/protobuf_utils.hpp
+++ b/src/common/protobuf_utils.hpp
@@ -121,7 +121,7 @@ mesos::slave::ContainerLimitation createContainerLimitation(
mesos::slave::ContainerState createContainerState(
- const ExecutorInfo& executorInfo,
+ const Option<ExecutorInfo>& executorInfo,
const ContainerID& id,
pid_t pid,
const std::string& directory);
[6/7] mesos git commit: Supported mesos containerizer destroy to be
nested aware.
Posted by ji...@apache.org.
Supported mesos containerizer destroy to be nested aware.
This patch makes the mesos containerizer destroy to be recursive.
To destroy a container with children nested under it, all its
children will be destroyed first, recursively. Then, the container
will get destroyed after all children destroy finish.
Review: https://reviews.apache.org/r/51674/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/837cbf72
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/837cbf72
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/837cbf72
Branch: refs/heads/master
Commit: 837cbf7276826b3c035dad88458c9b1b2f8da562
Parents: 2bc1aec
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 17:25:57 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 18:29:43 2016 -0700
----------------------------------------------------------------------
src/slave/containerizer/mesos/containerizer.cpp | 71 +++++++++++++-------
src/slave/containerizer/mesos/containerizer.hpp | 46 +++++++------
2 files changed, 71 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/837cbf72/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 21986ce..516d0e5 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1679,8 +1679,6 @@ Future<ContainerStatus> MesosContainerizerProcess::status(
Future<bool> MesosContainerizerProcess::destroy(
const ContainerID& containerId)
{
- CHECK(!containerId.has_parent());
-
if (!containers_.contains(containerId)) {
// This can happen due to the race between destroys initiated by
// the launch failure, the terminated executor and the agent so
@@ -1712,18 +1710,43 @@ Future<bool> MesosContainerizerProcess::destroy(
LOG(INFO) << "Destroying container " << containerId;
- if (container->state == PROVISIONING) {
+ // NOTE: We save the preivous state so that '_destroy' can properly
+ // cleanup based on the previous state of the container.
+ State previousState = container->state;
+
+ container->state = DESTROYING;
+
+ list<Future<bool>> destroys;
+ foreach (const ContainerID& child, container->containers) {
+ LOG(INFO) << "Destroying nested container " << child;
+ destroys.push_back(destroy(child));
+ }
+
+ return collect(destroys)
+ .then(defer(self(), &Self::_destroy, containerId, previousState));
+}
+
+
+Future<bool> MesosContainerizerProcess::_destroy(
+ const ContainerID& containerId,
+ const State& previousState)
+{
+ CHECK(containers_.contains(containerId));
+
+ const Owned<Container>& container = containers_[containerId];
+
+ CHECK_EQ(container->state, DESTROYING);
+
+ if (previousState == PROVISIONING) {
VLOG(1) << "Waiting for the provisioner to complete provisioning "
<< "before destroying container " << containerId;
- container->state = DESTROYING;
-
// Wait for the provisioner to finish provisioning before we
// start destroying the container.
container->provisioning
.onAny(defer(
self(),
- &Self::____destroy,
+ &Self::_____destroy,
containerId,
list<Future<Nothing>>()));
@@ -1731,12 +1754,10 @@ Future<bool> MesosContainerizerProcess::destroy(
.then([]() { return true; });
}
- if (container->state == PREPARING) {
+ if (previousState == PREPARING) {
VLOG(1) << "Waiting for the isolators to complete preparing "
<< "before destroying container " << containerId;
- container->state = DESTROYING;
-
// We need to wait for the isolators to finish preparing to
// prevent a race that the destroy method calls the 'cleanup'
// method of an isolator before the 'prepare' method is called.
@@ -1751,52 +1772,49 @@ Future<bool> MesosContainerizerProcess::destroy(
container->status.isSome()
? container->status.get()
: None())
- .onAny(defer(self(), &Self::___destroy, containerId));
+ .onAny(defer(self(), &Self::____destroy, containerId));
return container->termination.future()
.then([]() { return true; });
}
- if (container->state == ISOLATING) {
+ if (previousState == ISOLATING) {
VLOG(1) << "Waiting for the isolators to complete isolation "
<< "before destroying container " << containerId;
- container->state = DESTROYING;
-
// Wait for the isolators to finish isolating before we start
// to destroy the container.
container->isolation
- .onAny(defer(self(), &Self::_destroy, containerId));
+ .onAny(defer(self(), &Self::__destroy, containerId));
return container->termination.future()
.then([]() { return true; });
}
// Either RUNNING or FETCHING at this point.
- if (container->state == FETCHING) {
+ if (previousState == FETCHING) {
fetcher->kill(containerId);
}
- container->state = DESTROYING;
- _destroy(containerId);
+ __destroy(containerId);
return container->termination.future()
.then([]() { return true; });
}
-void MesosContainerizerProcess::_destroy(
+void MesosContainerizerProcess::__destroy(
const ContainerID& containerId)
{
CHECK(containers_.contains(containerId));
// Kill all processes then continue destruction.
launcher->destroy(containerId)
- .onAny(defer(self(), &Self::__destroy, containerId, lambda::_1));
+ .onAny(defer(self(), &Self::___destroy, containerId, lambda::_1));
}
-void MesosContainerizerProcess::__destroy(
+void MesosContainerizerProcess::___destroy(
const ContainerID& containerId,
const Future<Nothing>& future)
{
@@ -1827,21 +1845,21 @@ void MesosContainerizerProcess::__destroy(
CHECK_SOME(container->status);
container->status.get()
- .onAny(defer(self(), &Self::___destroy, containerId));
+ .onAny(defer(self(), &Self::____destroy, containerId));
}
-void MesosContainerizerProcess::___destroy(
+void MesosContainerizerProcess::____destroy(
const ContainerID& containerId)
{
CHECK(containers_.contains(containerId));
cleanupIsolators(containerId)
- .onAny(defer(self(), &Self::____destroy, containerId, lambda::_1));
+ .onAny(defer(self(), &Self::_____destroy, containerId, lambda::_1));
}
-void MesosContainerizerProcess::____destroy(
+void MesosContainerizerProcess::_____destroy(
const ContainerID& containerId,
const Future<list<Future<Nothing>>>& cleanups)
{
@@ -1876,11 +1894,11 @@ void MesosContainerizerProcess::____destroy(
}
provisioner->destroy(containerId)
- .onAny(defer(self(), &Self::_____destroy, containerId, lambda::_1));
+ .onAny(defer(self(), &Self::______destroy, containerId, lambda::_1));
}
-void MesosContainerizerProcess::_____destroy(
+void MesosContainerizerProcess::______destroy(
const ContainerID& containerId,
const Future<bool>& destroy)
{
@@ -1944,6 +1962,7 @@ void MesosContainerizerProcess::_____destroy(
}
container->termination.set(termination);
+
containers_.erase(containerId);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/837cbf72/src/slave/containerizer/mesos/containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.hpp b/src/slave/containerizer/mesos/containerizer.hpp
index ed037a1..f9ae873 100644
--- a/src/slave/containerizer/mesos/containerizer.hpp
+++ b/src/slave/containerizer/mesos/containerizer.hpp
@@ -190,6 +190,16 @@ public:
const process::Future<std::list<process::Future<Nothing>>>& future);
private:
+ enum State
+ {
+ PROVISIONING,
+ PREPARING,
+ ISOLATING,
+ FETCHING,
+ RUNNING,
+ DESTROYING
+ };
+
process::Future<Nothing> _recover(
const std::list<mesos::slave::ContainerState>& recoverable,
const hashset<ContainerID>& orphans);
@@ -231,25 +241,31 @@ private:
const ContainerID& containerId,
pid_t _pid);
- // Continues 'destroy()' once isolators has completed.
- void _destroy(const ContainerID& containerId);
+ // Continues 'destroy()' once nested containers are handled.
+ process::Future<bool> _destroy(
+ const ContainerID& containerId,
+ const State& previousState);
+
+ // Continues '_destroy()' once isolators has completed.
+ void __destroy(const ContainerID& containerId);
- // Continues '_destroy()' once all processes have been killed by the launcher.
- void __destroy(
+ // Continues '__destroy()' once all processes have been killed
+ // by the launcher.
+ void ___destroy(
const ContainerID& containerId,
const process::Future<Nothing>& future);
- // Continues '__destroy()' once we get the exit status of the executor.
- void ___destroy(const ContainerID& containerId);
+ // Continues '___destroy()' once we get the exit status of the container.
+ void ____destroy(const ContainerID& containerId);
- // Continues '___destroy()' once all isolators have completed
+ // Continues '____destroy()' once all isolators have completed
// cleanup.
- void ____destroy(
+ void _____destroy(
const ContainerID& containerId,
const process::Future<std::list<process::Future<Nothing>>>& cleanups);
- // Continues '____destroy()' once provisioner have completed destroy.
- void _____destroy(
+ // Continues '_____destroy()' once provisioner have completed destroy.
+ void ______destroy(
const ContainerID& containerId,
const process::Future<bool>& destroy);
@@ -281,16 +297,6 @@ private:
const process::Shared<Provisioner> provisioner;
const std::vector<process::Owned<mesos::slave::Isolator>> isolators;
- enum State
- {
- PROVISIONING,
- PREPARING,
- ISOLATING,
- FETCHING,
- RUNNING,
- DESTROYING
- };
-
struct Container
{
Container() : sequence("mesos-container-status-updates") {}
[3/7] mesos git commit: Changed ContainerConfig::ExecutorInfo from
required to optional.
Posted by ji...@apache.org.
Changed ContainerConfig::ExecutorInfo from required to optional.
For nested container launch in containerizer, a new launch method
was introduced for nested container only. However, 'ExecutorInfo'
is not included in this new launch method, only 'CommandInfo'
instead. To construct the 'ContainerConfig' for nested container
launch, we need to update the 'ExecutorInfo' in 'ContainerConfig'
from required to optional.
Review: https://reviews.apache.org/r/51669/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0b1021c6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0b1021c6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0b1021c6
Branch: refs/heads/master
Commit: 0b1021c6f4027781b40c82edbdbbb1c39e30ac2d
Parents: 83a6075
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 17:17:38 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 17:17:38 2016 -0700
----------------------------------------------------------------------
include/mesos/slave/containerizer.proto | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0b1021c6/include/mesos/slave/containerizer.proto
----------------------------------------------------------------------
diff --git a/include/mesos/slave/containerizer.proto b/include/mesos/slave/containerizer.proto
index 20db010..238dbb6 100644
--- a/include/mesos/slave/containerizer.proto
+++ b/include/mesos/slave/containerizer.proto
@@ -87,7 +87,7 @@ message ContainerRecoverInfo {
*/
message ContainerConfig {
// The executor associated with this container.
- required ExecutorInfo executor_info = 8;
+ optional ExecutorInfo executor_info = 8;
// The task (optional) associated with this container.
optional TaskInfo task_info = 9;
[2/7] mesos git commit: Changed the nested ContainerID from hashmap
to hashset in memory.
Posted by ji...@apache.org.
Changed the nested ContainerID from hashmap to hashset in memory.
To support nested containers, each container should maintain a list
of its children containers in structure. The tree-like structure is
not necessary though. We just need to keep a flat hashset for nested
containers.
Review: https://reviews.apache.org/r/51668/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/83a6075c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/83a6075c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/83a6075c
Branch: refs/heads/master
Commit: 83a6075c0b840b4dc02cb1920e939406d7eb5d03
Parents: c31887f
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 17:16:48 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 17:16:48 2016 -0700
----------------------------------------------------------------------
src/slave/containerizer/mesos/containerizer.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/83a6075c/src/slave/containerizer/mesos/containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.hpp b/src/slave/containerizer/mesos/containerizer.hpp
index cf0ec67..f41fd97 100644
--- a/src/slave/containerizer/mesos/containerizer.hpp
+++ b/src/slave/containerizer/mesos/containerizer.hpp
@@ -337,7 +337,7 @@ private:
process::Sequence sequence;
// Containers nested under this container.
- hashmap<ContainerID, process::Owned<Container>> containers;
+ hashset<ContainerID> containers;
};
hashmap<ContainerID, process::Owned<Container>> containers_;
[5/7] mesos git commit: Updated mesos containerizer isolate and
status for nested support.
Posted by ji...@apache.org.
Updated mesos containerizer isolate and status for nested support.
This patch simply removed the check.
Review: https://reviews.apache.org/r/51673/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2bc1aec1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2bc1aec1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2bc1aec1
Branch: refs/heads/master
Commit: 2bc1aec1da7c9c1059540f907c083435093e1533
Parents: 36ccc37
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 17:21:59 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 17:21:59 2016 -0700
----------------------------------------------------------------------
src/slave/containerizer/mesos/containerizer.cpp | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2bc1aec1/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 7482b33..21986ce 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1392,8 +1392,6 @@ Future<bool> MesosContainerizerProcess::isolate(
const ContainerID& containerId,
pid_t _pid)
{
- CHECK(!containerId.has_parent());
-
if (!containers_.contains(containerId)) {
return Failure("Container destroyed during preparing");
}
@@ -1653,8 +1651,6 @@ Future<ContainerStatus> _status(
Future<ContainerStatus> MesosContainerizerProcess::status(
const ContainerID& containerId)
{
- CHECK(!containerId.has_parent());
-
if (!containers_.contains(containerId)) {
return Failure("Unknown container: " + stringify(containerId));
}
[4/7] mesos git commit: Implemented containerizer::launch for nested
containers.
Posted by ji...@apache.org.
Implemented containerizer::launch for nested containers.
The containerizer launch for nested containers needs to share logic
with the top level container launch. Necessary information (e.g.,
user, SlaveId etc.) need to be included.
Review: https://reviews.apache.org/r/51670/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/36ccc372
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/36ccc372
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/36ccc372
Branch: refs/heads/master
Commit: 36ccc3723b14bd9115078b09f92da06b4754d1b4
Parents: 0b1021c
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Sep 26 17:18:55 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Sep 26 17:20:09 2016 -0700
----------------------------------------------------------------------
src/slave/containerizer/containerizer.hpp | 10 ++-
src/slave/containerizer/mesos/containerizer.cpp | 67 +++++++++++++++++---
src/slave/containerizer/mesos/containerizer.hpp | 14 ++--
src/slave/http.cpp | 9 ++-
src/tests/api_tests.cpp | 4 +-
src/tests/containerizer/mock_containerizer.hpp | 9 ++-
6 files changed, 92 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/36ccc372/src/slave/containerizer/containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/containerizer.hpp b/src/slave/containerizer/containerizer.hpp
index 47a8582..6b1f455 100644
--- a/src/slave/containerizer/containerizer.hpp
+++ b/src/slave/containerizer/containerizer.hpp
@@ -92,11 +92,17 @@ public:
// Launch a nested container.
// TODO(jieyu): Consider combining with the 'launch' above.
- virtual process::Future<Nothing> launch(
+ //
+ // TODO(gilbert): Remove the 'slaveId' once the fetcher does
+ // not rely on SlaveID.
+ virtual process::Future<bool> launch(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const Option<ContainerInfo>& containerInfo,
- const Resources& resources)
+ const Resources& resources,
+ const std::string& directory,
+ const Option<std::string>& user,
+ const SlaveID& slaveId)
{
return process::Failure("Unsupported");
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/36ccc372/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index a88e403..7482b33 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -490,25 +490,34 @@ Future<bool> MesosContainerizer::launch(
}
-Future<Nothing> MesosContainerizer::launch(
+Future<bool> MesosContainerizer::launch(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const Option<ContainerInfo>& containerInfo,
- const Resources& resources)
+ const Resources& resources,
+ const string& directory,
+ const Option<string>& user,
+ const SlaveID& slaveId)
{
// Need to disambiguate for the compiler.
- Future<Nothing> (MesosContainerizerProcess::*launch)(
+ Future<bool> (MesosContainerizerProcess::*launch)(
const ContainerID&,
const CommandInfo&,
const Option<ContainerInfo>&,
- const Resources&) = &MesosContainerizerProcess::launch;
+ const Resources&,
+ const string&,
+ const Option<string>&,
+ const SlaveID&) = &MesosContainerizerProcess::launch;
return dispatch(process.get(),
launch,
containerId,
commandInfo,
containerInfo,
- resources);
+ resources,
+ directory,
+ user,
+ slaveId);
}
@@ -910,6 +919,19 @@ Future<bool> MesosContainerizerProcess::launch(
container->config = containerConfig;
container->resources = containerConfig.resources();
+ // Maintain the 'children' list in the parent's 'Container' struct,
+ // which will be used for recursive destroy.
+ if (containerId.has_parent()) {
+ const ContainerID& parentContainerId = containerId.parent();
+ if (!containers_.contains(parentContainerId)) {
+ return Failure(
+ "Parent container " + stringify(parentContainerId) +
+ " does not exist");
+ }
+
+ containers_[parentContainerId]->containers.insert(containerId);
+ }
+
containers_.put(containerId, container);
// We'll first provision the image for the container, and
@@ -1442,13 +1464,42 @@ Future<bool> MesosContainerizerProcess::exec(
}
-Future<Nothing> MesosContainerizerProcess::launch(
+Future<bool> MesosContainerizerProcess::launch(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const Option<ContainerInfo>& containerInfo,
- const Resources& resources)
+ const Resources& resources,
+ const string& directory,
+ const Option<string>& user,
+ const SlaveID& slaveId)
{
- return Failure("Unsupported");
+ CHECK(containerId.has_parent());
+
+ if (containers_.contains(containerId)) {
+ return Failure(
+ "Nested container " + stringify(containerId) + " already started");
+ }
+
+ LOG(INFO) << "Starting nested container " << containerId;
+
+ ContainerConfig containerConfig;
+ containerConfig.mutable_command_info()->CopyFrom(commandInfo);
+ containerConfig.mutable_resources()->CopyFrom(resources);
+ containerConfig.set_directory(directory);
+
+ if (user.isSome()) {
+ containerConfig.set_user(user.get());
+ }
+
+ if (containerInfo.isSome()) {
+ containerConfig.mutable_container_info()->CopyFrom(containerInfo.get());
+ }
+
+ return launch(containerId,
+ containerConfig,
+ map<string, string>(),
+ slaveId,
+ false);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/36ccc372/src/slave/containerizer/mesos/containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.hpp b/src/slave/containerizer/mesos/containerizer.hpp
index f41fd97..ed037a1 100644
--- a/src/slave/containerizer/mesos/containerizer.hpp
+++ b/src/slave/containerizer/mesos/containerizer.hpp
@@ -85,11 +85,14 @@ public:
const std::map<std::string, std::string>& environment,
bool checkpoint);
- virtual process::Future<Nothing> launch(
+ virtual process::Future<bool> launch(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const Option<ContainerInfo>& containerInfo,
- const Resources& resources);
+ const Resources& resources,
+ const std::string& directory,
+ const Option<std::string>& user,
+ const SlaveID& slaveId);
virtual process::Future<Nothing> update(
const ContainerID& containerId,
@@ -150,11 +153,14 @@ public:
const std::map<std::string, std::string>& environment,
bool checkpoint);
- virtual process::Future<Nothing> launch(
+ virtual process::Future<bool> launch(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const Option<ContainerInfo>& containerInfo,
- const Resources& resources);
+ const Resources& resources,
+ const std::string& directory,
+ const Option<std::string>& user,
+ const SlaveID& slaveId);
virtual process::Future<Nothing> update(
const ContainerID& containerId,
http://git-wip-us.apache.org/repos/asf/mesos/blob/36ccc372/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 349d307..c1dbe98 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -1917,13 +1917,18 @@ Future<Response> Slave::Http::launchNestedContainer(
const ContainerID& containerId =
call.launch_nested_container().container_id();
- Future<Nothing> launched = slave->containerizer->launch(
+ // TODO(gilbert): The sandbox directory and user are incorrect,
+ // Please update it.
+ Future<bool> launched = slave->containerizer->launch(
containerId,
call.launch_nested_container().command(),
call.launch_nested_container().has_container()
? call.launch_nested_container().container()
: Option<ContainerInfo>::none(),
- call.launch_nested_container().resources());
+ call.launch_nested_container().resources(),
+ os::temp(),
+ None(),
+ slave->info.id());
// TODO(bmahler): The containerizers currently require that
// the caller calls destroy if the launch fails. See MESOS-6214.
http://git-wip-us.apache.org/repos/asf/mesos/blob/36ccc372/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index e857b17..334f4be 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -3345,8 +3345,8 @@ TEST_P(AgentAPITest, NestedContainerLaunch)
containerId.set_value(UUID::random().toString());
{
- EXPECT_CALL(mockContainerizer, launch(_, _, _, _))
- .WillOnce(Return(Future<Nothing>(Nothing())));
+ EXPECT_CALL(mockContainerizer, launch(_, _, _, _, _, _, _))
+ .WillOnce(Return(Future<bool>(true)));
v1::agent::Call call;
call.set_type(v1::agent::Call::LAUNCH_NESTED_CONTAINER);
http://git-wip-us.apache.org/repos/asf/mesos/blob/36ccc372/src/tests/containerizer/mock_containerizer.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/mock_containerizer.hpp b/src/tests/containerizer/mock_containerizer.hpp
index 840c511..79cfb90 100644
--- a/src/tests/containerizer/mock_containerizer.hpp
+++ b/src/tests/containerizer/mock_containerizer.hpp
@@ -57,13 +57,16 @@ public:
const std::map<std::string, std::string>&,
bool));
- MOCK_METHOD4(
+ MOCK_METHOD7(
launch,
- process::Future<Nothing>(
+ process::Future<bool>(
const ContainerID& containerId,
const CommandInfo& commandInfo,
const Option<ContainerInfo>& containerInfo,
- const Resources& resources));
+ const Resources& resources,
+ const std::string& directory,
+ const Option<std::string>& user,
+ const SlaveID& slaveId));
MOCK_METHOD2(
update,