You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by tn...@apache.org on 2015/05/25 07:31:40 UTC
[05/20] mesos git commit: Add slave id to docker container name
prefix.
Add slave id to docker container name prefix.
Review: https://reviews.apache.org/r/29327
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5acbfd2e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5acbfd2e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5acbfd2e
Branch: refs/heads/master
Commit: 5acbfd2e7907029d2979561a3876208941044fde
Parents: 9c5c927
Author: Timothy Chen <tn...@gmail.com>
Authored: Mon Nov 17 17:19:49 2014 -0800
Committer: Timothy Chen <tn...@apache.org>
Committed: Fri May 22 23:13:50 2015 -0700
----------------------------------------------------------------------
src/slave/containerizer/docker.cpp | 29 +++++++++++++++++++++++------
src/slave/containerizer/docker.hpp | 2 +-
2 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5acbfd2e/src/slave/containerizer/docker.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/docker.cpp b/src/slave/containerizer/docker.cpp
index 408a443..a37b45d 100644
--- a/src/slave/containerizer/docker.cpp
+++ b/src/slave/containerizer/docker.cpp
@@ -72,8 +72,6 @@ using state::RunState;
// Declared in header, see explanation there.
-// TODO(benh): At some point to run multiple slaves we'll need to make
-// the Docker container name creation include the slave ID.
const string DOCKER_NAME_PREFIX = "mesos-";
// Declared in header, see explanation there.
@@ -94,9 +92,25 @@ Option<ContainerID> parse(const Docker::Container& container)
}
if (name.isSome()) {
- ContainerID id;
- id.set_value(name.get());
- return id;
+ // For Mesos version <= 0.21.0, the docker container name format
+ // was DOCKER_NAME_PREFIX + containerId, and starting with 0.22.0
+ // it is changed to DOCKER_NAME_PREFIX + slaveId + "/" +
+ // containerId.
+ // To still be backward compatible during upgrade, we still need
+ // to load the previous format.
+ // TODO(tnachen): Remove this check after deprecation cycle.
+ if (!strings::contains(name.get(), "/")) {
+ ContainerID id;
+ id.set_value(name.get());
+ return id;
+ }
+
+ vector<string> parts = strings::split(name.get(), "/");
+ if (parts.size() == 2) {
+ ContainerID id;
+ id.set_value(parts[1]);
+ return id;
+ }
}
return None();
@@ -286,7 +300,10 @@ Try<Nothing> DockerContainerizerProcess::checkpoint(
Future<Nothing> DockerContainerizer::recover(
const Option<SlaveState>& state)
{
- return dispatch(process.get(), &DockerContainerizerProcess::recover, state);
+ return dispatch(
+ process.get(),
+ &DockerContainerizerProcess::recover,
+ state);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/5acbfd2e/src/slave/containerizer/docker.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/docker.hpp b/src/slave/containerizer/docker.hpp
index ed4ee19..f08520a 100644
--- a/src/slave/containerizer/docker.hpp
+++ b/src/slave/containerizer/docker.hpp
@@ -321,7 +321,7 @@ private:
std::string name()
{
- return DOCKER_NAME_PREFIX + stringify(id);
+ return DOCKER_NAME_PREFIX + slaveId.value() + "/" + stringify(id);
}
std::string image() const