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/12/12 21:05:39 UTC

[3/4] mesos git commit: Changed the timing of entering mount namespace for DEBUG container.

Changed the timing of entering mount namespace for DEBUG container.

Now, we entered the mount namespace of the target container for the
DEBUG container at the same place as we do pivot root for normal
containers. This behavior is more consistent.

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


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

Branch: refs/heads/master
Commit: 7781e30c5e8e82525624f08fd2c5f2e1c5252a73
Parents: 8238dbf
Author: Jie Yu <yu...@gmail.com>
Authored: Mon Dec 12 11:15:42 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Dec 12 11:30:31 2016 -0800

----------------------------------------------------------------------
 src/slave/containerizer/mesos/launch.cpp | 50 +++++++++++++--------------
 1 file changed, 25 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7781e30c/src/slave/containerizer/mesos/launch.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launch.cpp b/src/slave/containerizer/mesos/launch.cpp
index f90fce2..add4ca8 100644
--- a/src/slave/containerizer/mesos/launch.cpp
+++ b/src/slave/containerizer/mesos/launch.cpp
@@ -366,31 +366,6 @@ int MesosContainerizerLaunch::execute()
   }
 #endif // __WINDOWS__
 
-#ifdef __linux__
-  if (flags.namespace_mnt_target.isSome()) {
-    string path = path::join(
-        "/proc",
-        stringify(flags.namespace_mnt_target.get()),
-        "ns",
-        "mnt");
-
-    Try<Nothing> setns = ns::setns(path, "mnt", false);
-    if (setns.isError()) {
-      cerr << "Failed to enter mount namespace: "
-           << setns.error() << endl;
-      exitWithStatus(EXIT_FAILURE);
-    }
-  }
-
-  if (flags.unshare_namespace_mnt) {
-    if (unshare(CLONE_NEWNS) != 0) {
-      cerr << "Failed to unshare mount namespace: "
-           << os::strerror(errno) << endl;
-      exitWithStatus(EXIT_FAILURE);
-    }
-  }
-#endif // __linux__
-
   // Run additional preparation commands. These are run as the same
   // user and with the environment as the agent.
   foreach (const CommandInfo& command, launchInfo.pre_exec_commands()) {
@@ -507,6 +482,31 @@ int MesosContainerizerLaunch::execute()
   }
 #endif // __linux__
 
+#ifdef __linux__
+  if (flags.namespace_mnt_target.isSome()) {
+    string path = path::join(
+        "/proc",
+        stringify(flags.namespace_mnt_target.get()),
+        "ns",
+        "mnt");
+
+    Try<Nothing> setns = ns::setns(path, "mnt", false);
+    if (setns.isError()) {
+      cerr << "Failed to enter mount namespace: "
+           << setns.error() << endl;
+      exitWithStatus(EXIT_FAILURE);
+    }
+  }
+
+  if (flags.unshare_namespace_mnt) {
+    if (unshare(CLONE_NEWNS) != 0) {
+      cerr << "Failed to unshare mount namespace: "
+           << os::strerror(errno) << endl;
+      exitWithStatus(EXIT_FAILURE);
+    }
+  }
+#endif // __linux__
+
 #ifndef __WINDOWS__
   // Change root to a new root, if provided.
   if (launchInfo.has_rootfs()) {