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/06/22 23:01:03 UTC

[01/10] mesos git commit: Removed rootfs modules exclusion on appc provisioner test.

Repository: mesos
Updated Branches:
  refs/heads/master 4e54e81b7 -> f0ab05617


Removed rootfs modules exclusion on appc provisioner test.

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


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

Branch: refs/heads/master
Commit: e24af2ed780544b921630c8a2ab7fd4528b20000
Parents: 4e54e81
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:22 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:22 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/provisioner_appc_tests.cpp | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e24af2ed/src/tests/containerizer/provisioner_appc_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/provisioner_appc_tests.cpp b/src/tests/containerizer/provisioner_appc_tests.cpp
index 84fe52b..061f80c 100644
--- a/src/tests/containerizer/provisioner_appc_tests.cpp
+++ b/src/tests/containerizer/provisioner_appc_tests.cpp
@@ -808,11 +808,6 @@ protected:
     Try<Owned<Rootfs>> rootfs = LinuxRootfs::create(rootfsPath);
     ASSERT_SOME(rootfs);
 
-    // 'modules' directory is usually very large and is an easy one to exclude.
-    // TODO(jojy): Consider adding directory exclusion filter in LinuxRootfs.
-    Try<Nothing> rmdir = os::rmdir(path::join(rootfsPath, "lib", "modules"));
-    ASSERT_SOME(rmdir);
-
     Try<Nothing> manifestWrite = os::write(
         path::join(imagePath, "manifest"),
         manifest);


[03/10] mesos git commit: Fixed broken cni isolator test on centos7.

Posted by ji...@apache.org.
Fixed broken cni isolator test on centos7.

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


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

Branch: refs/heads/master
Commit: 7fca36322efef219eef008088abe91fe9ae8b7f2
Parents: eddf2ad
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:30 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:30 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/cni_isolator_tests.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7fca3632/src/tests/containerizer/cni_isolator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/cni_isolator_tests.cpp b/src/tests/containerizer/cni_isolator_tests.cpp
index a51f24b..6367e6a 100644
--- a/src/tests/containerizer/cni_isolator_tests.cpp
+++ b/src/tests/containerizer/cni_isolator_tests.cpp
@@ -180,8 +180,13 @@ TEST_F(CniIsolatorTest, ROOT_INTERNET_CURL_LaunchCommandTask)
 
   const Offer& offer = offers.get()[0];
 
+  // NOTE: We use a non-shell command here because 'sh' might not be
+  // in the PATH. 'alpine' does not specify env PATH in the image. On
+  // some linux distribution, '/sbin' is not in the PATH by default.
   CommandInfo command;
-  command.set_value("ifconfig");
+  command.set_shell(false);
+  command.set_value("/sbin/ifconfig");
+  command.add_arguments("ifconfig");
 
   TaskInfo task = createTask(
       offer.slave_id(),


[02/10] mesos git commit: Reduced test linux rootfs size.

Posted by ji...@apache.org.
Reduced test linux rootfs size.

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


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

Branch: refs/heads/master
Commit: eddf2ad4d1dba003de2e38877884c72851089c60
Parents: e24af2e
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:27 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:27 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/rootfs.hpp | 58 +++++++++++++++++++--------------
 1 file changed, 34 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/eddf2ad4/src/tests/containerizer/rootfs.hpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/rootfs.hpp b/src/tests/containerizer/rootfs.hpp
index 19ec7bf..26d0cfe 100644
--- a/src/tests/containerizer/rootfs.hpp
+++ b/src/tests/containerizer/rootfs.hpp
@@ -101,40 +101,50 @@ public:
       }
     }
 
-    std::vector<std::string> directories = {
-      "/bin",
-      "/lib",
-      "/lib64",
-      "/etc"
+    std::vector<std::string> files = {
+      "/bin/echo",
+      "/bin/ls",
+      "/bin/sh",
+      "/usr/bin/sh",
+      "/lib/x86_64-linux-gnu",
+      "/lib64/ld-linux-x86-64.so.2",
+      "/lib64/libc.so.6",
+      "/lib64/libdl.so.2",
+      "/lib64/libtinfo.so.5",
+      "/lib64/libselinux.so.1",
+      "/lib64/libpcre.so.1",
+      "/lib64/liblzma.so.5",
+      "/lib64/libpthread.so.0",
+      "/lib64/libcap.so.2",
+      "/lib64/libacl.so.1",
+      "/lib64/libattr.so.1",
+      "/lib64/librt.so.1",
+      "/etc/passwd"
     };
 
-    foreach (const std::string& directory, directories) {
+    foreach (const std::string& file, files) {
       // Some linux distros are moving all binaries and libraries to
       // /usr, in which case /bin, /lib, and /lib64 will be symlinks
       // to their equivalent directories in /usr.
-      Result<std::string> realpath = os::realpath(directory);
-      if (!realpath.isSome()) {
-        return Error("Failed to get realpath for '" +
-                     directory + "': " + (realpath.isError() ?
-                     realpath.error() : "No such directory"));
-      }
-
-      Try<Nothing> result = rootfs->add(realpath.get());
-      if (result.isError()) {
-        return Error("Failed to add '" + realpath.get() +
-                     "' to rootfs: " + result.error());
-      }
-
-      if (os::stat::islink(directory)) {
-        result = rootfs->add(directory);
+      Result<std::string> realpath = os::realpath(file);
+      if (realpath.isSome()) {
+        Try<Nothing> result = rootfs->add(realpath.get());
         if (result.isError()) {
-          return Error("Failed to add '" + directory + "' to rootfs: " +
-                       result.error());
+          return Error("Failed to add '" + realpath.get() +
+                       "' to rootfs: " + result.error());
+        }
+
+        if (file != realpath.get()) {
+          result = rootfs->add(file);
+          if (result.isError()) {
+            return Error("Failed to add '" + file + "' to rootfs: " +
+                         result.error());
+          }
         }
       }
     }
 
-    directories = {
+    std::vector<std::string> directories = {
       "/proc",
       "/sys",
       "/dev",


[06/10] mesos git commit: Fixed memory pressure test cgroup statistics.

Posted by ji...@apache.org.
Fixed memory pressure test cgroup statistics.

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


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

Branch: refs/heads/master
Commit: cefe4ce43f8048bb191c8fbdcbb9779741faeeeb
Parents: 3805ebb
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:39 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:39 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/memory_pressure_tests.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cefe4ce4/src/tests/containerizer/memory_pressure_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_pressure_tests.cpp b/src/tests/containerizer/memory_pressure_tests.cpp
index 4f343af..7d4c937 100644
--- a/src/tests/containerizer/memory_pressure_tests.cpp
+++ b/src/tests/containerizer/memory_pressure_tests.cpp
@@ -169,7 +169,7 @@ TEST_F(MemoryPressureMesosTest, CGROUPS_ROOT_Statistics)
   // Stop the memory-hammering task.
   driver.killTask(task.task_id());
 
-  AWAIT_READY(killed);
+  AWAIT_READY_FOR(killed, Seconds(120));
   EXPECT_EQ(task.task_id(), killed->task_id());
   EXPECT_EQ(TASK_KILLED, killed->state());
 


[07/10] mesos git commit: Fixed memory pressure test cgroup slave recovery.

Posted by ji...@apache.org.
Fixed memory pressure test cgroup slave recovery.

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


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

Branch: refs/heads/master
Commit: 87a78e8327f6f321351ef53eb07a44c86dde1a53
Parents: cefe4ce
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:43 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:43 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/memory_pressure_tests.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/87a78e83/src/tests/containerizer/memory_pressure_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_pressure_tests.cpp b/src/tests/containerizer/memory_pressure_tests.cpp
index 7d4c937..42ae323 100644
--- a/src/tests/containerizer/memory_pressure_tests.cpp
+++ b/src/tests/containerizer/memory_pressure_tests.cpp
@@ -260,7 +260,7 @@ TEST_F(MemoryPressureMesosTest, CGROUPS_ROOT_SlaveRecovery)
   EXPECT_EQ(TASK_RUNNING, running.get().state());
 
   // Wait for the ACK to be checkpointed.
-  AWAIT_READY(_statusUpdateAcknowledgement);
+  AWAIT_READY_FOR(_statusUpdateAcknowledgement, Seconds(120));
 
   // We restart the slave to let it recover.
   slave.get()->terminate();
@@ -323,7 +323,7 @@ TEST_F(MemoryPressureMesosTest, CGROUPS_ROOT_SlaveRecovery)
   // Stop the memory-hammering task.
   driver.killTask(task.task_id());
 
-  AWAIT_READY(killed);
+  AWAIT_READY_FOR(killed, Seconds(120));
   EXPECT_EQ(task.task_id(), killed->task_id());
   EXPECT_EQ(TASK_KILLED, killed->state());
 


[10/10] mesos git commit: Added space for ROOT_NC_HostToContainerUDP shell commands.

Posted by ji...@apache.org.
Added space for ROOT_NC_HostToContainerUDP shell commands.

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


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

Branch: refs/heads/master
Commit: f0ab056170fe81a67460cdf20a4ae77eb883a296
Parents: 4cfccf4
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:52 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:52 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/port_mapping_tests.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f0ab0561/src/tests/containerizer/port_mapping_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/port_mapping_tests.cpp b/src/tests/containerizer/port_mapping_tests.cpp
index 7ba7ec2..1c50cf5 100644
--- a/src/tests/containerizer/port_mapping_tests.cpp
+++ b/src/tests/containerizer/port_mapping_tests.cpp
@@ -808,15 +808,15 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_HostToContainerUDP)
 
   // Listen to 'localhost' and 'Port'.
   command1 << "nc -u -l localhost " << validPort << " > " << trafficViaLoopback
-           << "&";
+           << "& ";
 
   // Listen to 'public IP' and 'Port'.
   command1 << "nc -u -l " << hostIP << " " << validPort << " > "
-           << trafficViaPublic << "&";
+           << trafficViaPublic << "& ";
 
   // Listen to 'public IP' and 'invalidPort'. This should not receive anything.
   command1 << "nc -u -l " << invalidPort << " | tee " << trafficViaLoopback
-           << " " << trafficViaPublic << "&";
+           << " " << trafficViaPublic << "& ";
 
   // Touch the guard file.
   command1 << "touch " << container1Ready;


[09/10] mesos git commit: Fixed portmapping isolator tests ContainerId.

Posted by ji...@apache.org.
Fixed portmapping isolator tests ContainerId.

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


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

Branch: refs/heads/master
Commit: 4cfccf4b5bd14419d7248103e709bbc7eaae8833
Parents: f9a0db8
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:49 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:49 2016 -0700

----------------------------------------------------------------------
 src/tests/containerizer/port_mapping_tests.cpp | 28 ++++++++++-----------
 1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4cfccf4b/src/tests/containerizer/port_mapping_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/port_mapping_tests.cpp b/src/tests/containerizer/port_mapping_tests.cpp
index 21ad1e1..7ba7ec2 100644
--- a/src/tests/containerizer/port_mapping_tests.cpp
+++ b/src/tests/containerizer/port_mapping_tests.cpp
@@ -456,7 +456,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerTCP)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId1;
-  containerId1.set_value("container1");
+  containerId1.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -522,7 +522,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerTCP)
   ASSERT_TRUE(waitForFileCreation(container1Ready));
 
   ContainerID containerId2;
-  containerId2.set_value("container2");
+  containerId2.set_value(UUID::random().toString());
 
   executorInfo.mutable_resources()->CopyFrom(
       Resources::parse(container2Ports).get());
@@ -619,7 +619,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerUDP)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId1;
-  containerId1.set_value("container1");
+  containerId1.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -685,7 +685,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_ContainerToContainerUDP)
   ASSERT_TRUE(waitForFileCreation(container1Ready));
 
   ContainerID containerId2;
-  containerId2.set_value("container2");
+  containerId2.set_value(UUID::random().toString());
 
   executorInfo.mutable_resources()->CopyFrom(
       Resources::parse(container2Ports).get());
@@ -784,7 +784,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_HostToContainerUDP)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -902,7 +902,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_HostToContainerTCP)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -1028,7 +1028,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerICMPExternal)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -1115,7 +1115,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerICMPInternal)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -1205,7 +1205,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerARPExternal)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -1301,7 +1301,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_DNS)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -1393,7 +1393,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_TooManyContainers)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId1;
-  containerId1.set_value("container1");
+  containerId1.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -1443,7 +1443,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_TooManyContainers)
   ::close(pipes[1]);
 
   ContainerID containerId2;
-  containerId2.set_value("container2");
+  containerId2.set_value(UUID::random().toString());
 
   executorInfo.mutable_resources()->CopyFrom(
       Resources::parse(container2Ports).get());
@@ -1512,7 +1512,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_SmallEgressLimit)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.
@@ -1676,7 +1676,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_NC_PortMappingStatistics)
       Resources::parse(container1Ports).get());
 
   ContainerID containerId;
-  containerId.set_value("container1");
+  containerId.set_value(UUID::random().toString());
 
   // Use a relative temporary directory so it gets cleaned up
   // automatically with the test.


[05/10] mesos git commit: Added exception for etc hostname mount in cni isolator.

Posted by ji...@apache.org.
Added exception for etc hostname mount in cni isolator.

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


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

Branch: refs/heads/master
Commit: 3805ebb5d0926ba2af1fec2c0644b82c5b71ddc0
Parents: 1498c04
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:36 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:36 2016 -0700

----------------------------------------------------------------------
 .../mesos/isolators/network/cni/cni.cpp         | 41 +++++++++++---------
 1 file changed, 23 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3805ebb5/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
index 8cf5fcb..3e7c107 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -1498,25 +1498,30 @@ int NetworkCniIsolatorSetup::execute()
     // rootfs of host filesystem and will later pivot to the rootfs of
     // the container filesystem, when launching the task.
     if (!os::exists(file)) {
-      // NOTE: We just fail if the mount point does not exist on the
-      // host filesystem because we don't want to pollute the host
-      // filesystem.
-      cerr << "Mount point '" << file << "' does not exist "
-           << "on the host filesystem"<< endl;
-      return EXIT_FAILURE;
-    }
+      // Make an exception for `/etc/hostname`, because it may not
+      // exist on every system but hostname is still accessible by
+      // `getHostname()`.
+      if (file != "/etc/hostname") {
+        // NOTE: We just fail if the mount point does not exist on the
+        // host filesystem because we don't want to pollute the host
+        // filesystem.
+        cerr << "Mount point '" << file << "' does not exist "
+             << "on the host filesystem" << endl;
+        return EXIT_FAILURE;
+      }
+    } else {
+      mount = fs::mount(
+          source,
+          file,
+          None(),
+          MS_BIND,
+          nullptr);
 
-    mount = fs::mount(
-        source,
-        file,
-        None(),
-        MS_BIND,
-        nullptr);
-
-    if (mount.isError()) {
-      cerr << "Failed to bind mount from '" << source << "' to '"
-           << file << "': " << mount.error() << endl;
-      return EXIT_FAILURE;
+      if (mount.isError()) {
+        cerr << "Failed to bind mount from '" << source << "' to '"
+             << file << "': " << mount.error() << endl;
+        return EXIT_FAILURE;
+      }
     }
 
     // Do the bind mount in the container filesystem.


[04/10] mesos git commit: Added CGROUP namespace to ns helper.

Posted by ji...@apache.org.
Added CGROUP namespace to ns helper.

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


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

Branch: refs/heads/master
Commit: 1498c04bebd7e191021173c4d5f6705e4674c366
Parents: 7fca363
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:33 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:33 2016 -0700

----------------------------------------------------------------------
 src/linux/ns.hpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1498c04b/src/linux/ns.hpp
----------------------------------------------------------------------
diff --git a/src/linux/ns.hpp b/src/linux/ns.hpp
index 244a811..4e843b7 100644
--- a/src/linux/ns.hpp
+++ b/src/linux/ns.hpp
@@ -72,6 +72,10 @@
 #define CLONE_NEWUSER 0x10000000
 #endif
 
+#ifndef CLONE_NEWCGROUP
+#define CLONE_NEWCGROUP 0x02000000
+#endif
+
 namespace ns {
 
 // Returns all the supported namespaces by the kernel.
@@ -100,6 +104,7 @@ inline Try<int> nstype(const std::string& ns)
   nstypes["net"] = CLONE_NEWNET;
   nstypes["user"] = CLONE_NEWUSER;
   nstypes["pid"] = CLONE_NEWPID;
+  nstypes["cgroup"] = CLONE_NEWCGROUP;
 
   if (!nstypes.contains(ns)) {
     return Error("Unknown namespace '" + ns + "'");
@@ -310,7 +315,8 @@ inline std::string stringify(int flags)
     {CLONE_NEWIPC,  "CLONE_NEWIPC"},
     {CLONE_NEWPID,  "CLONE_NEWPID"},
     {CLONE_NEWNET,  "CLONE_NEWNET"},
-    {CLONE_NEWUSER, "CLONE_NEWUSER"}
+    {CLONE_NEWUSER, "CLONE_NEWUSER"},
+    {CLONE_NEWCGROUP, "CLONE_NEWCGROUP"}
   };
 
   std::vector<std::string> namespaces;


[08/10] mesos git commit: Fixed portmapping isolator bind mount root non-existed case.

Posted by ji...@apache.org.
Fixed portmapping isolator bind mount root non-existed case.

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


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

Branch: refs/heads/master
Commit: f9a0db8ef8ec5e9b22b41ddbbe6efb64b05da310
Parents: 87a78e8
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jun 22 16:00:46 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Wed Jun 22 16:00:46 2016 -0700

----------------------------------------------------------------------
 .../mesos/isolators/network/port_mapping.cpp     | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f9a0db8e/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
index 5df5918..25d2a57 100644
--- a/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/port_mapping.cpp
@@ -1877,11 +1877,20 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
   // each container. This is important because when we unmount the
   // network namespace handles on the host, those handles will be
   // unmounted in the containers as well, but NOT vice versa.
+  const string portMappingBindMountRoot = PORT_MAPPING_BIND_MOUNT_ROOT();
+
+  // We create the bind mount directory if it does not exist.
+  Try<Nothing> mkdir = os::mkdir(portMappingBindMountRoot);
+  if (mkdir.isError()) {
+    return Error(
+        "Failed to create the bind mount root directory at '" +
+        portMappingBindMountRoot + "': " + mkdir.error());
+  }
 
   // We need to get the realpath for the bind mount root since on some
   // Linux distribution, The bind mount root (i.e., /var/run/netns)
   // might contain symlink.
-  Result<string> bindMountRoot = os::realpath(PORT_MAPPING_BIND_MOUNT_ROOT());
+  Result<string> bindMountRoot = os::realpath(portMappingBindMountRoot);
   if (!bindMountRoot.isSome()) {
     return Error(
         "Failed to get realpath for bind mount root '" +
@@ -1889,14 +1898,6 @@ Try<Isolator*> PortMappingIsolatorProcess::create(const Flags& flags)
         (bindMountRoot.isError() ? bindMountRoot.error() : "Not found"));
   }
 
-  // We first create the bind mount directory if it does not exist.
-  Try<Nothing> mkdir = os::mkdir(bindMountRoot.get());
-  if (mkdir.isError()) {
-    return Error(
-        "Failed to create the bind mount root directory at " +
-        bindMountRoot.get() + ": " + mkdir.error());
-  }
-
   // Now, check '/proc/self/mounts' to see if the bind mount root has
   // already been self mounted.
   Try<fs::MountInfoTable> mountTable = fs::MountInfoTable::read();