Repository: mesos
Updated Branches:
  refs/heads/master 8620bf4a4 -> 4809d161e


Simplified master authentication.

Removes the wrapping by a Promise<Nothing> of the Authenticator
returned future from the master authentication. This should not
have any functional consequences.

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


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

Branch: refs/heads/master
Commit: 43abc2160f03a5b3fcc599a38b48a84f5c2b3f75
Parents: 8620bf4
Author: Till Toenshoff <[email protected]>
Authored: Fri Mar 27 15:24:02 2015 -0700
Committer: Adam B <[email protected]>
Committed: Fri Mar 27 15:24:02 2015 -0700

----------------------------------------------------------------------
 src/master/master.cpp | 14 +++-----------
 src/master/master.hpp |  8 ++++----
 2 files changed, 7 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/43abc216/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 7b60319..1d30c87 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -817,7 +817,7 @@ void Master::finalize()
 
   CHECK(offers.empty());
 
-  foreachvalue (Future<Nothing> future, authenticating) {
+  foreachvalue (Future<Option<string>> future, authenticating) {
     // NOTE: This is necessary during tests because a copy of
     // this future is used to setup authentication timeout. If a
     // test doesn't discard this future, authentication timeout might
@@ -3820,10 +3820,6 @@ void Master::authenticate(const UPID& from, const UPID& 
pid)
 
   LOG(INFO) << "Authenticating " << pid;
 
-  // Create a promise to capture the entire "authenticating"
-  // procedure. We'll set this _after_ we finish _authenticate.
-  Owned<Promise<Nothing>> promise(new Promise<Nothing>());
-
   // Create and initialize the authenticator.
   Authenticator* authenticator;
   // TODO(tillt): Allow multiple authenticators to be loaded and enable
@@ -3847,7 +3843,7 @@ void Master::authenticate(const UPID& from, const UPID& 
pid)
 
   // Start authentication.
   const Future<Option<string>>& future = authenticator_->authenticate()
-     .onAny(defer(self(), &Self::_authenticate, pid, promise, lambda::_1));
+     .onAny(defer(self(), &Self::_authenticate, pid, lambda::_1));
 
   // Don't wait for authentication to happen for ever.
   delay(Seconds(5),
@@ -3856,14 +3852,13 @@ void Master::authenticate(const UPID& from, const UPID& 
pid)
         future);
 
   // Save our state.
-  authenticating[pid] = promise->future();
+  authenticating[pid] = future;
   authenticators.put(pid, authenticator_);
 }
 
 
 void Master::_authenticate(
     const UPID& pid,
-    const Owned<Promise<Nothing>>& promise,
     const Future<Option<string>>& future)
 {
   if (!future.isReady() || future.get().isNone()) {
@@ -3873,13 +3868,10 @@ void Master::_authenticate(
 
     LOG(WARNING) << "Failed to authenticate " << pid
                  << ": " << error;
-
-    promise->fail(error);
   } else {
     LOG(INFO) << "Successfully authenticated principal '" << future.get().get()
               << "' at " << pid;
 
-    promise->set(Nothing());
     authenticated.put(pid, future.get().get());
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/43abc216/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 3c957ab..744886e 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -298,7 +298,6 @@ protected:
   // 'future' is the future returned by the authenticator.
   void _authenticate(
       const process::UPID& pid,
-      const process::Owned<process::Promise<Nothing>>& promise,
       const process::Future<Option<std::string>>& future);
 
   void authenticationTimeout(process::Future<Option<std::string>> future);
@@ -652,9 +651,10 @@ private:
   std::vector<std::string> authenticatorNames;
 
   // Frameworks/slaves that are currently in the process of authentication.
-  // 'authenticating' future for an authenticatee is ready when it is
-  // authenticated.
-  hashmap<process::UPID, process::Future<Nothing>> authenticating;
+  // 'authenticating' future is completed when authenticator
+  // completes authentication.
+  // The future is removed from the map when master completes authentication.
+  hashmap<process::UPID, process::Future<Option<std::string>>> authenticating;
 
   hashmap<process::UPID, process::Owned<Authenticator>> authenticators;
 

Reply via email to