You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by me...@apache.org on 2014/11/12 23:55:30 UTC

[1/2] mesos git commit: Added module loading to scheduler driver.

Repository: mesos
Updated Branches:
  refs/heads/master be1d6833e -> 02097c821


Added module loading to scheduler driver.

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


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

Branch: refs/heads/master
Commit: 167f1b348bb1890b0de9aa4a864f31109a75f5c3
Parents: be1d683
Author: Till Toenshoff <to...@me.com>
Authored: Wed Nov 12 14:54:44 2014 -0800
Committer: Adam B <ad...@mesosphere.io>
Committed: Wed Nov 12 14:54:44 2014 -0800

----------------------------------------------------------------------
 src/sched/flags.hpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/sched/sched.cpp | 14 +++++++++++++
 2 files changed, 66 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/167f1b34/src/sched/flags.hpp
----------------------------------------------------------------------
diff --git a/src/sched/flags.hpp b/src/sched/flags.hpp
index 62a634b..e1c1c25 100644
--- a/src/sched/flags.hpp
+++ b/src/sched/flags.hpp
@@ -21,8 +21,12 @@
 
 #include <stout/flags.hpp>
 
+#include "common/parse.hpp"
+
 #include "logging/flags.hpp"
 
+#include "messages/messages.hpp"
+
 #include "sched/constants.hpp"
 
 namespace mesos {
@@ -43,9 +47,57 @@ public:
         "failover timeout/10, if failover timeout is specified) or " +
         stringify(REGISTRATION_RETRY_INTERVAL_MAX) + ", whichever is smaller",
         REGISTRATION_BACKOFF_FACTOR);
+
+    // This help message for --modules flag is the same for
+    // {master,slave,tests,sched}/flags.hpp and should always be kept
+    // in sync.
+    // TODO(karya): Remove the JSON example and add reference to the
+    // doc file explaining the --modules flag.
+    add(&Flags::modules,
+        "modules",
+        "List of modules to be loaded and be available to the internal\n"
+        "subsystems.\n"
+        "\n"
+        "Use --modules=filepath to specify the list of modules via a\n"
+        "file containing a JSON formatted string. 'filepath' can be\n"
+        "of the form 'file:///path/to/file' or '/path/to/file'.\n"
+        "\n"
+        "Use --modules=\"{...}\" to specify the list of modules inline.\n"
+        "\n"
+        "Example:\n"
+        "{\n"
+        "  \"libraries\": [\n"
+        "    {\n"
+        "      \"file\": \"/path/to/libfoo.so\",\n"
+        "      \"modules\": [\n"
+        "        {\n"
+        "          \"name\": \"org_apache_mesos_bar\",\n"
+        "          \"parameters\": [\n"
+        "            {\n"
+        "              \"key\": \"X\",\n"
+        "              \"value\": \"Y\"\n"
+        "            }\n"
+        "          ]\n"
+        "        },\n"
+        "        {\n"
+        "          \"name\": \"org_apache_mesos_baz\"\n"
+        "        }\n"
+        "      ]\n"
+        "    },\n"
+        "    {\n"
+        "      \"name\": \"qux\",\n"
+        "      \"modules\": [\n"
+        "        {\n"
+        "          \"name\": \"org_apache_mesos_norf\"\n"
+        "        }\n"
+        "      ]\n"
+        "    }\n"
+        "  ]\n"
+        "}");
   }
 
   Duration registration_backoff_factor;
+  Option<Modules> modules;
 };
 
 } // namespace scheduler {

http://git-wip-us.apache.org/repos/asf/mesos/blob/167f1b34/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index d662182..aef88ac 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -31,6 +31,7 @@
 #include <sstream>
 
 #include <mesos/mesos.hpp>
+#include <mesos/module.hpp>
 #include <mesos/scheduler.hpp>
 
 #include <process/defer.hpp>
@@ -75,6 +76,8 @@
 
 #include "messages/messages.hpp"
 
+#include "module/manager.hpp"
+
 #include "sched/constants.hpp"
 #include "sched/flags.hpp"
 
@@ -1278,6 +1281,17 @@ Status MesosSchedulerDriver::start()
     return status;
   }
 
+  // Initialize modules. Note that since other subsystems may depend
+  // upon modules, we should initialize modules before anything else.
+  if (flags.modules.isSome()) {
+    Try<Nothing> result = modules::ModuleManager::load(flags.modules.get());
+    if (result.isError()) {
+      status = DRIVER_ABORTED;
+      scheduler->error(this, "Error loading modules: " + result.error());
+      return status;
+    }
+  }
+
   CHECK(process == NULL);
 
   if (credential == NULL) {


[2/2] mesos git commit: Integrated CRAM-MD5 Test Authenticatee module into scheduler.

Posted by me...@apache.org.
Integrated CRAM-MD5 Test Authenticatee module into scheduler.

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


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

Branch: refs/heads/master
Commit: 02097c8219ee2cdb1949e252302ee36701812bcf
Parents: 167f1b3
Author: Till Toenshoff <to...@me.com>
Authored: Wed Nov 12 14:54:56 2014 -0800
Committer: Adam B <ad...@mesosphere.io>
Committed: Wed Nov 12 14:54:56 2014 -0800

----------------------------------------------------------------------
 src/sched/constants.cpp |  2 ++
 src/sched/constants.hpp |  3 +++
 src/sched/flags.hpp     |  8 ++++++++
 src/sched/sched.cpp     | 16 +++++++++++++++-
 4 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/02097c82/src/sched/constants.cpp
----------------------------------------------------------------------
diff --git a/src/sched/constants.cpp b/src/sched/constants.cpp
index 44ccfbe..517ca5c 100644
--- a/src/sched/constants.cpp
+++ b/src/sched/constants.cpp
@@ -31,6 +31,8 @@ const Duration REGISTRATION_BACKOFF_FACTOR = Seconds(2);
 
 const Duration REGISTRATION_RETRY_INTERVAL_MAX = Minutes(1);
 
+const std::string DEFAULT_AUTHENTICATEE = "crammd5";
+
 } // namespace scheduler {
 } // namespace internal {
 } // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/02097c82/src/sched/constants.hpp
----------------------------------------------------------------------
diff --git a/src/sched/constants.hpp b/src/sched/constants.hpp
index 63707a8..ac497b2 100644
--- a/src/sched/constants.hpp
+++ b/src/sched/constants.hpp
@@ -33,6 +33,9 @@ extern const Duration REGISTRATION_BACKOFF_FACTOR;
 // registration.
 extern const Duration REGISTRATION_RETRY_INTERVAL_MAX;
 
+// Name of the default, CRAM-MD5 authenticatee.
+extern const std::string DEFAULT_AUTHENTICATEE;
+
 } // namespace scheduler {
 } // namespace internal {
 } // namespace mesos {

http://git-wip-us.apache.org/repos/asf/mesos/blob/02097c82/src/sched/flags.hpp
----------------------------------------------------------------------
diff --git a/src/sched/flags.hpp b/src/sched/flags.hpp
index e1c1c25..4e0d56f 100644
--- a/src/sched/flags.hpp
+++ b/src/sched/flags.hpp
@@ -94,10 +94,18 @@ public:
         "    }\n"
         "  ]\n"
         "}");
+
+    add(&Flags::authenticatee,
+        "authenticatee",
+        "Authenticatee implementation to use when authenticating against the\n"
+        "master. Use the default '" + DEFAULT_AUTHENTICATEE + "', or\n"
+        "load an alternate authenticatee module using MESOS_MODULES.",
+        DEFAULT_AUTHENTICATEE);
   }
 
   Duration registration_backoff_factor;
   Option<Modules> modules;
+  std::string authenticatee;
 };
 
 } // namespace scheduler {

http://git-wip-us.apache.org/repos/asf/mesos/blob/02097c82/src/sched/sched.cpp
----------------------------------------------------------------------
diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp
index aef88ac..a9c111e 100644
--- a/src/sched/sched.cpp
+++ b/src/sched/sched.cpp
@@ -76,6 +76,7 @@
 
 #include "messages/messages.hpp"
 
+#include "module/authenticatee.hpp"
 #include "module/manager.hpp"
 
 #include "sched/constants.hpp"
@@ -301,7 +302,20 @@ protected:
     CHECK_SOME(credential);
 
     CHECK(authenticatee == NULL);
-    authenticatee = new cram_md5::CRAMMD5Authenticatee();
+
+    if (flags.authenticatee == scheduler::DEFAULT_AUTHENTICATEE) {
+      LOG(INFO) << "Using default CRAM-MD5 authenticatee";
+      authenticatee = new cram_md5::CRAMMD5Authenticatee();
+    } else {
+      Try<Authenticatee*> module =
+        modules::ModuleManager::create<Authenticatee>(flags.authenticatee);
+      if (module.isError()) {
+        EXIT(1) << "Could not create authenticatee module '"
+                << flags.authenticatee << "': " << module.error();
+      }
+      LOG(INFO) << "Using '" << flags.authenticatee << "' authenticatee";
+      authenticatee = module.get();
+    }
 
     // NOTE: We do not pass 'Owned<Authenticatee>' here because doing
     // so could make 'AuthenticateeProcess' responsible for deleting