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 2016/07/22 09:43:26 UTC

[2/6] mesos git commit: Separated readonly and readwrite realms in libprocess.

Separated readonly and readwrite realms in libprocess.

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


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

Branch: refs/heads/1.0.x
Commit: a76800c78e18b3c27ab4476d90035123d49c0951
Parents: 6cd20e9
Author: Zhitao Li <zh...@gmail.com>
Authored: Thu Jul 21 22:39:02 2016 -0700
Committer: Adam B <ad...@mesosphere.io>
Committed: Fri Jul 22 02:02:24 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/gtest.hpp    |  3 ++-
 3rdparty/libprocess/include/process/process.hpp  | 14 ++++++++++----
 3rdparty/libprocess/src/process.cpp              |  9 +++++----
 3rdparty/libprocess/src/tests/main.cpp           |  5 ++++-
 3rdparty/libprocess/src/tests/metrics_tests.cpp  |  6 +++---
 3rdparty/libprocess/src/tests/profiler_tests.cpp |  6 +++---
 6 files changed, 27 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a76800c7/3rdparty/libprocess/include/process/gtest.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/gtest.hpp b/3rdparty/libprocess/include/process/gtest.hpp
index 21f66ed..80d26db 100644
--- a/3rdparty/libprocess/include/process/gtest.hpp
+++ b/3rdparty/libprocess/include/process/gtest.hpp
@@ -28,7 +28,8 @@
 
 namespace process {
 
-constexpr char DEFAULT_HTTP_AUTHENTICATION_REALM[] = "libprocess-realm";
+constexpr char READONLY_HTTP_AUTHENTICATION_REALM[] = "libprocess-readonly";
+constexpr char READWRITE_HTTP_AUTHENTICATION_REALM[] = "libprocess-readwrite";
 
 // A simple test event listener that makes sure to resume the clock
 // after each test even if the previous test had a partial result

http://git-wip-us.apache.org/repos/asf/mesos/blob/a76800c7/3rdparty/libprocess/include/process/process.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/process.hpp b/3rdparty/libprocess/include/process/process.hpp
index 2e85d31..54c7d2e 100644
--- a/3rdparty/libprocess/include/process/process.hpp
+++ b/3rdparty/libprocess/include/process/process.hpp
@@ -483,9 +483,14 @@ protected:
  * for it (e.g., a logging directory) via environment variables.
  *
  * @param delegate Process to receive root HTTP requests.
- * @param authenticationRealm The authentication realm that libprocess-level
- *     HTTP endpoints will be installed under, if any. If this realm is not
- *     specified, endpoints will be installed without authentication.
+ * @param readwriteAuthenticationRealm The authentication realm that read-write
+ *     libprocess-level HTTP endpoints will be installed under, if any.
+ *     If this realm is not specified, read-write endpoints will be installed
+ *     without authentication.
+ * @param readonlyAuthenticationRealm The authentication realm that read-only
+ *     libprocess-level HTTP endpoints will be installed under, if any.
+ *     If this realm is not specified, read-only endpoints will be installed
+ *     without authentication.
  * @return `true` if this was the first invocation of `process::initialize()`,
  *     or `false` if it was not the first invocation.
  *
@@ -493,7 +498,8 @@ protected:
  */
 bool initialize(
     const Option<std::string>& delegate = None(),
-    const Option<std::string>& authenticationRealm = None());
+    const Option<std::string>& readwriteAuthenticationRealm = None(),
+    const Option<std::string>& readonlyAuthenticationRealm = None());
 
 
 /**

http://git-wip-us.apache.org/repos/asf/mesos/blob/a76800c7/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 7e8bebe..d0a7a40 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -814,7 +814,8 @@ void install(vector<Owned<FirewallRule>>&& rules)
 
 bool initialize(
     const Option<string>& delegate,
-    const Option<string>& authenticationRealm)
+    const Option<string>& readwriteAuthenticationRealm,
+    const Option<string>& readonlyAuthenticationRealm)
 {
   // TODO(benh): Return an error if attempting to initialize again
   // with a different delegate than originally specified.
@@ -1040,13 +1041,13 @@ bool initialize(
   help = spawn(new Help(delegate), true);
 
   // Initialize the global metrics process.
-  metrics::initialize(authenticationRealm);
+  metrics::initialize(readonlyAuthenticationRealm);
 
   // Create the global logging process.
-  _logging = spawn(new Logging(authenticationRealm), true);
+  _logging = spawn(new Logging(readwriteAuthenticationRealm), true);
 
   // Create the global profiler process.
-  spawn(new Profiler(authenticationRealm), true);
+  spawn(new Profiler(readwriteAuthenticationRealm), true);
 
   // Create the global system statistics process.
   spawn(new System(), true);

http://git-wip-us.apache.org/repos/asf/mesos/blob/a76800c7/3rdparty/libprocess/src/tests/main.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/main.cpp b/3rdparty/libprocess/src/tests/main.cpp
index a03dbc4..023b4fe 100644
--- a/3rdparty/libprocess/src/tests/main.cpp
+++ b/3rdparty/libprocess/src/tests/main.cpp
@@ -51,7 +51,10 @@ int main(int argc, char** argv)
   testing::InitGoogleMock(&argc, argv);
 
   // Initialize libprocess.
-  process::initialize(None(), process::DEFAULT_HTTP_AUTHENTICATION_REALM);
+  process::initialize(
+      None(),
+      process::READWRITE_HTTP_AUTHENTICATION_REALM,
+      process::READONLY_HTTP_AUTHENTICATION_REALM);
 
   // NOTE: Windows does not support signal semantics required for these
   // handlers to be useful.

http://git-wip-us.apache.org/repos/asf/mesos/blob/a76800c7/3rdparty/libprocess/src/tests/metrics_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/metrics_tests.cpp b/3rdparty/libprocess/src/tests/metrics_tests.cpp
index 5a82f4f..7c74b89 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -50,11 +50,11 @@ using metrics::Gauge;
 using metrics::Timer;
 
 using process::Clock;
-using process::DEFAULT_HTTP_AUTHENTICATION_REALM;
 using process::Failure;
 using process::Future;
 using process::PID;
 using process::Process;
+using process::READONLY_HTTP_AUTHENTICATION_REALM;
 using process::Statistics;
 using process::UPID;
 
@@ -509,10 +509,10 @@ TEST_F(MetricsTest, SnapshotAuthenticationEnabled)
 
   process::Owned<Authenticator> authenticator(
     new BasicAuthenticator(
-        DEFAULT_HTTP_AUTHENTICATION_REALM, {{"foo", "bar"}}));
+        READONLY_HTTP_AUTHENTICATION_REALM, {{"foo", "bar"}}));
 
   AWAIT_READY(
-      setAuthenticator(DEFAULT_HTTP_AUTHENTICATION_REALM, authenticator));
+      setAuthenticator(READONLY_HTTP_AUTHENTICATION_REALM, authenticator));
 
   UPID upid("metrics", process::address());
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/a76800c7/3rdparty/libprocess/src/tests/profiler_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/profiler_tests.cpp b/3rdparty/libprocess/src/tests/profiler_tests.cpp
index bf7a375..995bd02 100644
--- a/3rdparty/libprocess/src/tests/profiler_tests.cpp
+++ b/3rdparty/libprocess/src/tests/profiler_tests.cpp
@@ -35,8 +35,8 @@ using http::OK;
 using http::Response;
 using http::Unauthorized;
 
-using process::DEFAULT_HTTP_AUTHENTICATION_REALM;
 using process::Future;
+using process::READWRITE_HTTP_AUTHENTICATION_REALM;
 using process::UPID;
 
 using std::string;
@@ -121,10 +121,10 @@ TEST_F(ProfilerTest, StartAndStopAuthenticationEnabled)
 {
   process::Owned<Authenticator> authenticator(
     new BasicAuthenticator(
-        DEFAULT_HTTP_AUTHENTICATION_REALM, {{"foo", "bar"}}));
+        READWRITE_HTTP_AUTHENTICATION_REALM, {{"foo", "bar"}}));
 
   AWAIT_READY(
-      setAuthenticator(DEFAULT_HTTP_AUTHENTICATION_REALM, authenticator));
+      setAuthenticator(READWRITE_HTTP_AUTHENTICATION_REALM, authenticator));
 
   UPID upid("profiler", process::address());