You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ya...@apache.org on 2016/07/30 05:53:42 UTC

[1/4] mesos git commit: Fixed the CORS error when redirecting in webUI.

Repository: mesos
Updated Branches:
  refs/heads/jyx/1.0.x [created] 094c8976c


Fixed the CORS error when redirecting in webUI.

The redirection in webUI is broken due to the CORS restriction after
we enabled redirection in `master/state` endpoint in MESOS-1865.
As a workaround we change the request mechanism for `master/state`
endpoint from XHR to JSONP to bypass the CORS restriction.

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


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

Branch: refs/heads/jyx/1.0.x
Commit: 4bcdcdb39789681a87c005068ac15203a17a031b
Parents: 0b48f26
Author: haosdent huang <ha...@gmail.com>
Authored: Fri Jul 29 16:31:13 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Fri Jul 29 22:49:39 2016 -0700

----------------------------------------------------------------------
 src/webui/master/static/index.html        |  5 ---
 src/webui/master/static/js/controllers.js | 43 +++++++-------------------
 2 files changed, 11 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4bcdcdb3/src/webui/master/static/index.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/index.html b/src/webui/master/static/index.html
index a083537..6211892 100644
--- a/src/webui/master/static/index.html
+++ b/src/webui/master/static/index.html
@@ -57,11 +57,6 @@
         <div class="alert" data-ng-show="state &amp;&amp; !state.leader">
           <strong>No master is currently leading ...</strong>
         </div>
-        <div class="alert alert-warning hide" id="not-leader-alert">
-          <button class="close" data-dismiss="alert">�</button>
-          <strong>This master is <u>not the leader</u>, redirecting in {{redirect / 1000}} seconds ...</strong>
-          <a href="/master/redirect">go now</a>
-        </div>
 
         <div data-ng-repeat="alert in currentAlerts" class="alert alert-{{ alert.type }}">
           <p data-ng-show="alert.title">

http://git-wip-us.apache.org/repos/asf/mesos/blob/4bcdcdb3/src/webui/master/static/js/controllers.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/controllers.js b/src/webui/master/static/js/controllers.js
index ceaf140..cf8c2a4 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -51,35 +51,13 @@
 
 
   // Update the outermost scope with the new state.
-  function updateState($scope, $timeout, data) {
-    // Don't do anything if the data hasn't changed.
-    if ($scope.data == data) {
+  function updateState($scope, $timeout, state) {
+    // Don't do anything if the state hasn't changed.
+    if ($scope.state == state) {
       return true; // Continue polling.
     }
 
-    $scope.state = JSON.parse(data);
-
-    // Determine if there is a leader (and redirect if not the leader).
-    if ($scope.state.leader) {
-
-      // Redirect if we aren't the leader.
-      if ($scope.state.leader != $scope.state.pid) {
-        $scope.redirect = 6000;
-        $("#not-leader-alert").removeClass("hide");
-
-        var countdown = function() {
-          if ($scope.redirect == 0) {
-            // TODO(benh): Use '$window'.
-            window.location = '/master/redirect';
-          } else {
-            $scope.redirect = $scope.redirect - 1000;
-            $timeout(countdown, 1000);
-          }
-        };
-        countdown();
-        return false; // Don't continue polling.
-      }
-    }
+    $scope.state = state;
 
     // A cluster is named if the state returns a non-empty string name.
     // Track whether this cluster is named in a Boolean for display purposes.
@@ -96,8 +74,6 @@
       return true;
     }
 
-    $scope.data = data;
-
     // Pass this pollTime to all relativeDate calls to make them all relative to
     // the same moment in time.
     //
@@ -396,10 +372,13 @@
     };
 
     var pollState = function() {
-      $http.get('master/state',
-                {transformResponse: function(data) { return data; }})
-        .success(function(data) {
-          if (updateState($scope, $timeout, data)) {
+      // When the current master is not the leader, the request is redirected to
+      // the leading master automatically. This would cause a CORS error if we
+      // use XMLHttpRequest here. To avoid the CORS error, we use JSONP as a
+      // workaround. Please refer to MESOS-5911 for further details.
+      $http.jsonp('master/state?jsonp=JSON_CALLBACK')
+        .success(function(response) {
+          if (updateState($scope, $timeout, response)) {
             $scope.delay = updateInterval(_.size($scope.agents));
             $timeout(pollState, $scope.delay);
           }


[4/4] mesos git commit: Added MESOS-5911 to 1.0.1 CHANGELOG.

Posted by ya...@apache.org.
Added MESOS-5911 to 1.0.1 CHANGELOG.


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

Branch: refs/heads/jyx/1.0.x
Commit: 094c8976c4e9f119e626fb4164510a90034da9db
Parents: 4bcdcdb
Author: Jiang Yan Xu <xu...@apple.com>
Authored: Fri Jul 29 22:53:01 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Fri Jul 29 22:53:01 2016 -0700

----------------------------------------------------------------------
 CHANGELOG | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/094c8976/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 0bb3cf8..61c326d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ Release Notes - Mesos - Version 1.0.1
 
 All Issues:
 ** Bug
+  * [MESOS-5911] - webUI redirection to leader in browser does not work.
   * [MESOS-5913] - Stale socket FD usage when using libevent + SSL.
 
 


[3/4] mesos git commit: Added `URL::isAbsolute` to check if the URL is absolute.

Posted by ya...@apache.org.
Added `URL::isAbsolute` to check if the URL is absolute.

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


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

Branch: refs/heads/jyx/1.0.x
Commit: 2bb3e2314f60fe2b8e80df7b6bab000e736eea1d
Parents: f74bad3
Author: haosdent huang <ha...@gmail.com>
Authored: Fri Jul 29 15:59:28 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Fri Jul 29 22:49:39 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/http.hpp | 6 ++++++
 3rdparty/libprocess/src/http.cpp             | 6 ++++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2bb3e231/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index c17c047..404196b 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -153,6 +153,12 @@ struct URL
 
   static Try<URL> parse(const std::string& urlString);
 
+  /**
+   * Returns whether the URL is absolute.
+   * See https://tools.ietf.org/html/rfc3986#section-4.3 for details.
+   */
+  bool isAbsolute() const;
+
   Option<std::string> scheme;
 
   // TODO(benh): Consider using unrestricted union for 'domain' and 'ip'.

http://git-wip-us.apache.org/repos/asf/mesos/blob/2bb3e231/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 1bf1f3b..298bd46 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -243,6 +243,12 @@ Try<URL> URL::parse(const string& urlString)
 }
 
 
+bool URL::isAbsolute() const
+{
+  return scheme.isSome();
+}
+
+
 bool Request::acceptsEncoding(const string& encoding) const
 {
   // From RFC 2616:


[2/4] mesos git commit: Fixed the incomplete redirect url in `Master::Http::redirect()`.

Posted by ya...@apache.org.
Fixed the incomplete redirect url in `Master::Http::redirect()`.

When the request which contains query parameters is sent to a
non-leading master, the master would redirect ignoring the query
parameters. This patch changes redirect() to include them.

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


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

Branch: refs/heads/jyx/1.0.x
Commit: 0b48f26f81556f21f2a11c4c7cb90a799f34fe93
Parents: 2bb3e23
Author: haosdent huang <ha...@gmail.com>
Authored: Fri Jul 29 16:10:16 2016 -0700
Committer: Jiang Yan Xu <xu...@apple.com>
Committed: Fri Jul 29 22:49:39 2016 -0700

----------------------------------------------------------------------
 src/master/http.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0b48f26f/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 1ecbc01..efd0524 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -2035,7 +2035,11 @@ Future<Response> Master::Http::redirect(const Request& request) const
     // base url of leading master to avoid infinite redirect loop.
     return TemporaryRedirect(basePath);
   } else {
-    return TemporaryRedirect(basePath + request.url.path);
+    // `request.url` is not absolute so we can safely append it to
+    // `basePath`. See https://tools.ietf.org/html/rfc2616#section-5.1.2
+    // for details.
+    CHECK(!request.url.isAbsolute());
+    return TemporaryRedirect(basePath + stringify(request.url));
   }
 }