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/07/18 16:45:27 UTC

[3/3] mesos git commit: Ignored /etc/* mounts to host filesystems if host network is used.

Ignored /etc/* mounts to host filesystems if host network is used.

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


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

Branch: refs/heads/master
Commit: 0bf29fac911912cd89192f01aebd11ba7fc7605d
Parents: cca92ce
Author: Jie Yu <yu...@gmail.com>
Authored: Fri Jul 15 18:37:04 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Jul 18 09:45:20 2016 -0700

----------------------------------------------------------------------
 .../mesos/isolators/network/cni/cni.cpp         | 54 +++++++++++---------
 1 file changed, 30 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0bf29fac/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 11b826e..5360781 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -1515,30 +1515,36 @@ int NetworkCniIsolatorSetup::execute()
     // command executor since command executor will be launched with
     // rootfs of host filesystem and will later pivot to the rootfs of
     // the container filesystem, when launching the task.
-    if (!os::exists(file)) {
-      // 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);
-
-      if (mount.isError()) {
-        cerr << "Failed to bind mount from '" << source << "' to '"
-             << file << "': " << mount.error() << endl;
-        return EXIT_FAILURE;
+    //
+    // NOTE: We only need to do this if non host network is used.
+    // Currently, we use `flags.hostname1 to distinguish if a host
+    // network is being used or not.
+    if (flags.hostname.isSome()) {
+      if (!os::exists(file)) {
+        // 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);
+
+        if (mount.isError()) {
+          cerr << "Failed to bind mount from '" << source << "' to '"
+               << file << "': " << mount.error() << endl;
+          return EXIT_FAILURE;
+        }
       }
     }