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 2015/10/26 21:11:46 UTC

mesos git commit: Added function that verifies prerequisites for using Linux launcher.

Repository: mesos
Updated Branches:
  refs/heads/master 7a9b49084 -> b0c773181


Added function that verifies prerequisites for using Linux launcher.

We recently switched to using LinuxLauncher by default. This causes
problems with running the slave in a Docker container.

This patch introduces a function for checking whether the machine is
suited for running Linux launcher. For the time being it checks whether
the freezer cgroup subsystem enabled, as the Linux launcher evolves we
might want to add more checks.

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


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

Branch: refs/heads/master
Commit: b0c77318169c50428b5da262aca70626091c30eb
Parents: 7a9b490
Author: Artem Harutyunyan <ar...@mesosphere.io>
Authored: Mon Oct 26 11:55:51 2015 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Oct 26 13:11:35 2015 -0700

----------------------------------------------------------------------
 src/slave/containerizer/linux_launcher.cpp      | 13 +++++++++++++
 src/slave/containerizer/linux_launcher.hpp      |  3 +++
 src/slave/containerizer/mesos/containerizer.cpp |  5 ++---
 3 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/b0c77318/src/slave/containerizer/linux_launcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/linux_launcher.cpp b/src/slave/containerizer/linux_launcher.cpp
index 654f0e1..c0adb34 100644
--- a/src/slave/containerizer/linux_launcher.cpp
+++ b/src/slave/containerizer/linux_launcher.cpp
@@ -178,6 +178,19 @@ Try<Launcher*> LinuxLauncher::create(const Flags& flags)
 }
 
 
+bool LinuxLauncher::available()
+{
+  // Make sure:
+  //   - we run as root
+  //   - cgroups are enabled
+  //   - "freezer" subsytem is available.
+
+  return ::geteuid() == 0 &&
+         cgroups::enabled() &&
+         cgroups::hierarchy("freezer").isSome();
+}
+
+
 Future<hashset<ContainerID>> LinuxLauncher::recover(
     const std::list<ContainerState>& states)
 {

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0c77318/src/slave/containerizer/linux_launcher.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/linux_launcher.hpp b/src/slave/containerizer/linux_launcher.hpp
index 35b3315..627df89 100644
--- a/src/slave/containerizer/linux_launcher.hpp
+++ b/src/slave/containerizer/linux_launcher.hpp
@@ -35,6 +35,9 @@ class LinuxLauncher : public Launcher
 public:
   static Try<Launcher*> create(const Flags& flags);
 
+  // Returns 'true' if prerequisites for using LinuxLauncher are available.
+  static bool available();
+
   virtual ~LinuxLauncher() {}
 
   virtual process::Future<hashset<ContainerID>> recover(

http://git-wip-us.apache.org/repos/asf/mesos/blob/b0c77318/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 0664d00..91e4ea3 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -225,9 +225,8 @@ Try<MesosContainerizer*> MesosContainerizer::create(
       return Error("Unknown or unsupported launcher: " + flags_.launcher.get());
     }
   } else {
-    // If the user has not specified the launcher, use Linux launcher
-    // if running as root, posix launcher otherwise.
-    launcher = (::geteuid() == 0)
+    // Use Linux launcher if it is available, POSIX otherwise.
+    launcher = LinuxLauncher::available()
       ? LinuxLauncher::create(flags_)
       : PosixLauncher::create(flags_);
   }