[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mesos-commits
Subject:    git commit: Exposed VETH_PREFIX and used mesos instead of veth.
From:       jieyu () apache ! org
Date:       2014-06-26 21:13:38
Message-ID: c632824f9dc74e2d8cb9b20c9a75480e () git ! apache ! org
[Download RAW message or body]

Repository: mesos
Updated Branches:
  refs/heads/master 44cfde68b -> cdf5aa8de


Exposed VETH_PREFIX and used mesos instead of veth.

Review: https://reviews.apache.org/r/23089


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cdf5aa8d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cdf5aa8d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cdf5aa8d

Branch: refs/heads/master
Commit: cdf5aa8deb29711ef0fcf9154bdbf129b3d74405
Parents: 44cfde6
Author: Jie Yu <yujie.jay@gmail.com>
Authored: Thu Jun 26 14:13:26 2014 -0700
Committer: Jie Yu <yujie.jay@gmail.com>
Committed: Thu Jun 26 14:13:26 2014 -0700

----------------------------------------------------------------------
 .../isolators/network/port_mapping.cpp          | 13 +++++++++----
 .../isolators/network/port_mapping.hpp          |  4 ++++
 src/tests/isolator_tests.cpp                    | 20 +++++++++-----------
 3 files changed, 22 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cdf5aa8d/src/slave/containerizer/isolators/network/port_mapping.cpp
                
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/network/port_mapping.cpp \
b/src/slave/containerizer/isolators/network/port_mapping.cpp index 6f8dd17..a326653 \
                100644
--- a/src/slave/containerizer/isolators/network/port_mapping.cpp
+++ b/src/slave/containerizer/isolators/network/port_mapping.cpp
@@ -88,6 +88,9 @@ namespace mesos {
 namespace internal {
 namespace slave {
 
+const std::string VETH_PREFIX = "mesos";
+
+
 // The root directory where we bind mount all the namespace handles.
 // We choose the directory '/var/run/netns' so that we can use
 // iproute2 suite (e.g., ip netns show/exec) to inspect or enter the
@@ -165,15 +168,17 @@ static uint32_t roundDownToPowerOfTwo(uint32_t x)
 // executor process.
 static string veth(pid_t pid)
 {
-  return "veth" + stringify(pid);
+  return VETH_PREFIX + stringify(pid);
 }
 
 
 // Extracts the pid from the given veth name.
 static Option<pid_t> getPid(string veth)
 {
-  if (strings::startsWith(veth, "veth")) {
-    Try<pid_t> pid = numify<pid_t>(veth.substr(strlen("veth")));
+  if (strings::startsWith(veth, VETH_PREFIX)) {
+    Try<pid_t> pid = numify<pid_t>(
+        strings::remove(veth, VETH_PREFIX, strings::PREFIX));
+
     if (pid.isSome()) {
       return pid.get();
     }
@@ -1071,7 +1076,7 @@ Future<Nothing> PortMappingIsolatorProcess::recover(
   hashset<pid_t> pids;
   foreach (const string& name, links.get()) {
     Option<pid_t> pid = getPid(name);
-    // Not all links follow the naming: veth{pid}, so we simply
+    // Not all links follow the naming: mesos{pid}, so we simply
     // continue, e.g., eth0.
     if (pid.isNone()) {
       continue;

http://git-wip-us.apache.org/repos/asf/mesos/blob/cdf5aa8d/src/slave/containerizer/isolators/network/port_mapping.hpp
                
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/isolators/network/port_mapping.hpp \
b/src/slave/containerizer/isolators/network/port_mapping.hpp index 9ef28bc..ac3bee3 \
                100644
--- a/src/slave/containerizer/isolators/network/port_mapping.hpp
+++ b/src/slave/containerizer/isolators/network/port_mapping.hpp
@@ -45,6 +45,10 @@ namespace mesos {
 namespace internal {
 namespace slave {
 
+// The prefix this isolator uses for the virtual ethernet devices.
+extern const std::string VETH_PREFIX;
+
+
 // Responsible for allocating ephemeral ports for the port mapping
 // network isolator. This class is exposed mainly for unit testing.
 class EphemeralPortsAllocator

http://git-wip-us.apache.org/repos/asf/mesos/blob/cdf5aa8d/src/tests/isolator_tests.cpp
                
----------------------------------------------------------------------
diff --git a/src/tests/isolator_tests.cpp b/src/tests/isolator_tests.cpp
index a07142c..4650f97 100644
--- a/src/tests/isolator_tests.cpp
+++ b/src/tests/isolator_tests.cpp
@@ -103,8 +103,6 @@ using mesos::internal::slave::LinuxLauncher;
 #endif // __linux__
 #ifdef WITH_NETWORK_ISOLATOR
 using mesos::internal::slave::MesosContainerizerLaunch;
-#endif // WITH_NETWORK_ISOLATOR
-#ifdef WITH_NETWORK_ISOLATOR
 using mesos::internal::slave::PortMappingIsolatorProcess;
 #endif // WITH_NETWORK_ISOLATOR
 using mesos::internal::slave::PosixLauncher;
@@ -765,23 +763,23 @@ public:
   {
     ASSERT_SOME(routing::check())
       << "-------------------------------------------------------------\n"
-      << "We cannot run any PortMappingIsolatorTests because your libnl\n"
-      << "library is not new enough. You can either install a\n"
+      << "We cannot run any PortMappingIsolatorTests because your\n"
+      << "libnl library is not new enough. You can either install a\n"
       << "new libnl library, or disable this test case\n"
       << "-------------------------------------------------------------";
 
     ASSERT_SOME_EQ(0, os::shell(NULL, "which nc"))
       << "-------------------------------------------------------------\n"
       << "We cannot run any PortMappingIsolatorTests because 'nc'\n"
-      << "could not be found. You can either install a\n"
-      << "nc, or disable this test case\n"
+      << "could not be found. You can either install 'nc', or disable\n"
+      << "this test case\n"
       << "-------------------------------------------------------------";
 
-    ASSERT_SOME_EQ(0, os::shell(NULL, "arping -V"))
+    ASSERT_SOME_EQ(0, os::shell(NULL, "which arping"))
       << "-------------------------------------------------------------\n"
-      << "We cannot run some PortMappingIsolatorTests because 'arping -V'\n"
-      << "could not be run successfully. You can either check\n"
-      << "arping, or disable this test case\n"
+      << "We cannot run some PortMappingIsolatorTests because 'arping'\n"
+      << "could not be found. You can either isntall 'arping', or\n"
+      << "disable this test case\n"
       << "-------------------------------------------------------------";
   }
 
@@ -888,7 +886,7 @@ protected:
     Try<set<string> > links = net::links();
     ASSERT_SOME(links);
     foreach (const string& name, links.get()) {
-      if (strings::startsWith(name, "veth")) {
+      if (strings::startsWith(name, slave::VETH_PREFIX)) {
         ASSERT_SOME_TRUE(link::remove(name));
       }
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic