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 <[email protected]>
Authored: Wed Nov 12 14:54:56 2014 -0800
Committer: Adam B <[email protected]>
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

Reply via email to