Repository: mesos Updated Branches: refs/heads/master 6c84cbd7f -> 012c9eeeb
Restored Linux/Posix launcher creation logic for MesosContainerizer. The current logic uses LinuxLauncher if running as root. However, this causes problems with cgroups freezer when we launch multiple Agents inside the test suite. Review: https://reviews.apache.org/r/38660 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/012c9eee Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/012c9eee Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/012c9eee Branch: refs/heads/master Commit: 012c9eeeb8fc000d5f3a7b69c1019c886d731c85 Parents: 6c84cbd Author: Kapil Arya <[email protected]> Authored: Wed Sep 23 14:52:50 2015 -0700 Committer: Jie Yu <[email protected]> Committed: Wed Sep 23 15:19:00 2015 -0700 ---------------------------------------------------------------------- src/slave/containerizer/mesos/containerizer.cpp | 27 +++++++++++++++----- src/slave/flags.cpp | 8 ++++++ src/slave/flags.hpp | 1 + src/tests/event_call_framework_test.sh | 3 +++ src/tests/java_framework_test.sh | 3 +++ src/tests/no_executor_framework_test.sh | 3 +++ src/tests/persistent_volume_framework_test.sh | 3 +++ src/tests/python_framework_test.sh | 3 +++ src/tests/test_framework_test.sh | 3 +++ 9 files changed, 48 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/slave/containerizer/mesos/containerizer.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp index b4a77e7..19b63b9 100644 --- a/src/slave/containerizer/mesos/containerizer.cpp +++ b/src/slave/containerizer/mesos/containerizer.cpp @@ -215,13 +215,28 @@ Try<MesosContainerizer*> MesosContainerizer::create( } #ifdef __linux__ - // Always use LinuxLauncher if running as root since we will be picking - // namespaces during the fork() call. - Try<Launcher*> launcher = - (geteuid() == 0) - ? LinuxLauncher::create(flags_) - : PosixLauncher::create(flags_); + Try<Launcher*> launcher = (Launcher*) NULL; + if (flags_.launcher.isSome()) { + // If the user has specified the launcher, use it. + if (flags_.launcher.get() == "linux") { + launcher = LinuxLauncher::create(flags_); + } else if (flags_.launcher.get() == "posix") { + launcher = PosixLauncher::create(flags_); + } else { + 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) + ? LinuxLauncher::create(flags_) + : PosixLauncher::create(flags_); + } #else + if (flags_.launcher.isSome() && flags_.launcher.get() != "posix") { + return Error("Unsupported launcher: " + flags_.launcher.get()); + } + Try<Launcher*> launcher = PosixLauncher::create(flags_); #endif // __linux__ http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/slave/flags.cpp ---------------------------------------------------------------------- diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp index add4196..6164b4b 100644 --- a/src/slave/flags.cpp +++ b/src/slave/flags.cpp @@ -59,6 +59,14 @@ mesos::internal::slave::Flags::Flags() "for the Mesos Containerizer.", "posix/cpu,posix/mem"); + add(&Flags::launcher, + "launcher", + "The launcher to be used for Mesos containerizer. It could either be\n" + "linux or posix. The linux launcher is required for cgroups isolation\n" + "and for any isolators that require Linux namespaces such as network,\n" + "pid, etc. If unspecified, the slave will choose the linux launcher if\n" + "it's running as root on linux and started with --isolation flag."); + add(&Flags::image_providers, "image_providers", "Comma separated list of supported image providers,\n" http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/slave/flags.hpp ---------------------------------------------------------------------- diff --git a/src/slave/flags.hpp b/src/slave/flags.hpp index e31a418..b8d6bb4 100644 --- a/src/slave/flags.hpp +++ b/src/slave/flags.hpp @@ -46,6 +46,7 @@ public: Option<std::string> hostname; Option<std::string> resources; std::string isolation; + Option<std::string> launcher; Option<std::string> image_providers; std::string image_provisioner_backend; http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/tests/event_call_framework_test.sh ---------------------------------------------------------------------- diff --git a/src/tests/event_call_framework_test.sh b/src/tests/event_call_framework_test.sh index 85394b5..9d12115 100755 --- a/src/tests/event_call_framework_test.sh +++ b/src/tests/event_call_framework_test.sh @@ -30,6 +30,9 @@ export MESOS_RESOURCES="cpus:2;mem:10240" # Set isolation for the slave. export MESOS_ISOLATION="filesystem/posix,posix/cpu,posix/mem" +# Set launcher for the slave. +export MESOS_LAUNCHER="posix" + # Disable authentication as the scheduler library does not support it. export MESOS_AUTHENTICATE=false http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/tests/java_framework_test.sh ---------------------------------------------------------------------- diff --git a/src/tests/java_framework_test.sh b/src/tests/java_framework_test.sh index bab4336..8fccc69 100755 --- a/src/tests/java_framework_test.sh +++ b/src/tests/java_framework_test.sh @@ -30,5 +30,8 @@ export MESOS_RESOURCES="cpus:2;mem:10240" # Set isolation for the slave. export MESOS_ISOLATION="filesystem/posix,posix/cpu,posix/mem" +# Set launcher for the slave. +export MESOS_LAUNCHER="posix" + # Check that the Java test framework executes without crashing (returns 0). exec $MESOS_BUILD_DIR/src/examples/java/test-framework local http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/tests/no_executor_framework_test.sh ---------------------------------------------------------------------- diff --git a/src/tests/no_executor_framework_test.sh b/src/tests/no_executor_framework_test.sh index 11d34c8..aebdc8c 100755 --- a/src/tests/no_executor_framework_test.sh +++ b/src/tests/no_executor_framework_test.sh @@ -30,5 +30,8 @@ export MESOS_RESOURCES="cpus:2;mem:10240" # Set isolation for the slave. export MESOS_ISOLATION="filesystem/posix,posix/cpu,posix/mem" +# Set launcher for the slave. +export MESOS_LAUNCHER="posix" + # Check that the C++ test framework executes without crashing (returns 0). exec ${MESOS_BUILD_DIR}/src/no-executor-framework --master=local --num_tasks=5 http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/tests/persistent_volume_framework_test.sh ---------------------------------------------------------------------- diff --git a/src/tests/persistent_volume_framework_test.sh b/src/tests/persistent_volume_framework_test.sh index 33bf9c7..84f0284 100755 --- a/src/tests/persistent_volume_framework_test.sh +++ b/src/tests/persistent_volume_framework_test.sh @@ -27,5 +27,8 @@ export MESOS_NUM_SLAVES=3 # Set isolation for the slave. export MESOS_ISOLATION="filesystem/posix,posix/cpu,posix/mem" +# Set launcher for the slave. +export MESOS_LAUNCHER="posix" + # Check that the framework executes without crashing (returns 0). exec ${MESOS_BUILD_DIR}/src/persistent-volume-framework --master=local http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/tests/python_framework_test.sh ---------------------------------------------------------------------- diff --git a/src/tests/python_framework_test.sh b/src/tests/python_framework_test.sh index 88bce21..dc3a50f 100755 --- a/src/tests/python_framework_test.sh +++ b/src/tests/python_framework_test.sh @@ -30,5 +30,8 @@ export MESOS_RESOURCES="cpus:2;mem:10240" # Set isolation for the slave. export MESOS_ISOLATION="filesystem/posix,posix/cpu,posix/mem" +# Set launcher for the slave. +export MESOS_LAUNCHER="posix" + # Check that the Python test framework executes without crashing (returns 0). exec $MESOS_BUILD_DIR/src/examples/python/test-framework local http://git-wip-us.apache.org/repos/asf/mesos/blob/012c9eee/src/tests/test_framework_test.sh ---------------------------------------------------------------------- diff --git a/src/tests/test_framework_test.sh b/src/tests/test_framework_test.sh index b13cdd8..409e809 100755 --- a/src/tests/test_framework_test.sh +++ b/src/tests/test_framework_test.sh @@ -30,5 +30,8 @@ export MESOS_RESOURCES="cpus:2;mem:10240" # Set isolation for the slave. export MESOS_ISOLATION="filesystem/posix,posix/cpu,posix/mem" +# Set launcher for the slave. +export MESOS_LAUNCHER="posix" + # Check that the C++ test framework executes without crashing (returns 0). exec ${MESOS_BUILD_DIR}/src/test-framework --master=local
