You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/10/27 17:26:31 UTC
[2/2] mesos git commit: Fixed the broken metrics information of
master in WebUI.
Fixed the broken metrics information of master in WebUI.
After we introduced redirection on `/master/state` endpoint to the
leading master in `c9153336`, the metrics information in the WebUI
was broken when the current master is not the leading master.
In this patch, we retrieve the leading master from `/master/state`
endpoint and ensure that requests to `/metrics/snapshot` and `/state`
endpoints are always sent to the leading master.
Review: https://reviews.apache.org/r/53172/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b2fc5888
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b2fc5888
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b2fc5888
Branch: refs/heads/master
Commit: b2fc58883e2cd0ca144fd1b0e10cad4235a50223
Parents: 34eb567
Author: haosdent huang <ha...@gmail.com>
Authored: Thu Oct 27 10:22:18 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Thu Oct 27 10:22:18 2016 -0700
----------------------------------------------------------------------
src/webui/master/static/js/controllers.js | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b2fc5888/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 3dead4f..dd0cc81 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -241,8 +241,7 @@
}
// Update the outermost scope with the metrics/snapshot endpoint.
- function updateMetrics($scope, $timeout, data) {
- var metrics = JSON.parse(data);
+ function updateMetrics($scope, $timeout, metrics) {
$scope.staging_tasks = metrics['master/tasks_staging'];
$scope.starting_tasks = metrics['master/tasks_starting'];
$scope.running_tasks = metrics['master/tasks_running'];
@@ -325,6 +324,18 @@
if (!matched) $scope.navbarActiveTab = null;
});
+ var leadingMasterURL = function(path) {
+ // Use current location as address in case we could not find the
+ // leading master.
+ var address = location.hostname + ':' + location.port;
+ if ($scope.state && $scope.state.leader_info) {
+ address = $scope.state.leader_info.hostname + ':' +
+ $scope.state.leader_info.port;
+ }
+
+ return '//' + address + path;
+ }
+
var popupErrorModal = function() {
if ($scope.delay >= 128000) {
$scope.delay = 2000;
@@ -384,7 +395,7 @@
// 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')
+ $http.jsonp(leadingMasterURL('/master/state?jsonp=JSON_CALLBACK'))
.success(function(response) {
if (updateState($scope, $timeout, response)) {
$scope.delay = updateInterval(_.size($scope.agents));
@@ -399,10 +410,9 @@
};
var pollMetrics = function() {
- $http.get('metrics/snapshot',
- {transformResponse: function(data) { return data; }})
- .success(function(data) {
- if (updateMetrics($scope, $timeout, data)) {
+ $http.jsonp(leadingMasterURL('/metrics/snapshot?jsonp=JSON_CALLBACK'))
+ .success(function(response) {
+ if (updateMetrics($scope, $timeout, response)) {
$scope.delay = updateInterval(_.size($scope.agents));
$timeout(pollMetrics, $scope.delay);
}