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/04/07 19:32:50 UTC
mesos git commit: Add support for docker user-defined networks.
Repository: mesos
Updated Branches:
refs/heads/master 0f2f17aaf -> b18f5bf48
Add support for docker user-defined networks.
Review: https://reviews.apache.org/r/42516/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b18f5bf4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b18f5bf4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b18f5bf4
Branch: refs/heads/master
Commit: b18f5bf48fda12bce9c2ac8e762a08f537ffb41d
Parents: 0f2f17a
Author: Ezra Silvera <ez...@il.ibm.com>
Authored: Thu Apr 7 10:32:25 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Apr 7 10:32:25 2016 -0700
----------------------------------------------------------------------
include/mesos/mesos.proto | 1 +
include/mesos/v1/mesos.proto | 1 +
src/docker/docker.cpp | 30 ++++++++++++++++++++++++++++--
3 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b18f5bf4/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index e1fc02e..63c181a 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1690,6 +1690,7 @@ message ContainerInfo {
HOST = 1;
BRIDGE = 2;
NONE = 3;
+ USER = 4;
}
optional Network network = 2 [default = HOST];
http://git-wip-us.apache.org/repos/asf/mesos/blob/b18f5bf4/include/mesos/v1/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/v1/mesos.proto b/include/mesos/v1/mesos.proto
index 35789e0..a60a834 100644
--- a/include/mesos/v1/mesos.proto
+++ b/include/mesos/v1/mesos.proto
@@ -1689,6 +1689,7 @@ message ContainerInfo {
HOST = 1;
BRIDGE = 2;
NONE = 3;
+ USER = 4;
}
optional Network network = 2 [default = HOST];
http://git-wip-us.apache.org/repos/asf/mesos/blob/b18f5bf4/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index bb9ddde..19cf424 100755
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -551,6 +551,31 @@ Future<Nothing> Docker::run(
case ContainerInfo::DockerInfo::HOST: network = "host"; break;
case ContainerInfo::DockerInfo::BRIDGE: network = "bridge"; break;
case ContainerInfo::DockerInfo::NONE: network = "none"; break;
+ case ContainerInfo::DockerInfo::USER: {
+ // User defined networks require docker version >= 1.9.0.
+ Try<Nothing> validateVer = validateVersion(Version(1, 9, 0));
+
+ if (validateVer.isError()) {
+ return Failure("User defined networks require Docker "
+ "version 1.9.0 or higher");
+ }
+
+ if (containerInfo.network_infos_size() == 0) {
+ return Failure("No network info found in container info");
+ }
+
+ if (containerInfo.network_infos_size() > 1) {
+ return Failure("Only a single network can be defined in Docker run");
+ }
+
+ const NetworkInfo& networkInfo = containerInfo.network_infos(0);
+ if(!networkInfo.has_name()){
+ return Failure("No network name found in network info");
+ }
+
+ network = networkInfo.name();
+ break;
+ }
default: return Failure("Unsupported Network mode: " +
stringify(dockerInfo.network()));
}
@@ -571,8 +596,9 @@ Future<Nothing> Docker::run(
}
if (dockerInfo.port_mappings().size() > 0) {
- if (network != "bridge") {
- return Failure("Port mappings are only supported for bridge network");
+ if (network == "host" || network == "none" ) {
+ return Failure("Port mappings are only supported for bridge and "
+ "user-defined networks");
}
if (!resources.isSome()) {