mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject [05/10] mesos git commit: Added exception for etc hostname mount in cni isolator.
Date Wed, 22 Jun 2016 23:01:07 GMT
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 <songzihao1990@gmail.com>
Authored: Wed Jun 22 16:00:36 2016 -0700
Committer: Jie Yu <yujie.jay@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.


Mime
View raw message