You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ss...@apache.org on 2013/08/02 06:13:25 UTC

git commit: Added link to executor sandbox from framework template

Updated Branches:
  refs/heads/master 21722e8a9 -> f6d95e89e


Added link to executor sandbox from framework template

The framework page is rendered with info from the master, but the
sandbox directory is known only by the slave. To link to the directory
from a page rendered by the master, create a page in between that acts
as a redirector by first asking for the directory from the slave.

If the sandbox is important for linking, the master could return
`executor.directory` in the `state.json` endpoint and negate the need
for this redirection stuff.

Review: http://reviews.apache.org/r/13006


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

Branch: refs/heads/master
Commit: f6d95e89ecc232ec2418ced8279e8e277e56fffa
Parents: 21722e8
Author: Ross Allen <re...@gmail.com>
Authored: Sat Jul 27 22:27:59 2013 -0700
Committer: Ross Allen <re...@gmail.com>
Committed: Thu Aug 1 21:11:45 2013 -0700

----------------------------------------------------------------------
 src/webui/master/static/framework.html       | 13 ++++
 src/webui/master/static/js/app.js            | 12 ++++
 src/webui/master/static/js/controllers.js    | 72 +++++++++++++++++++++++
 src/webui/master/static/slave_executor.html  |  8 +--
 src/webui/master/static/slave_framework.html |  4 +-
 5 files changed, 103 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f6d95e89/src/webui/master/static/framework.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/framework.html b/src/webui/master/static/framework.html
index 0cedb39..1973cbe 100644
--- a/src/webui/master/static/framework.html
+++ b/src/webui/master/static/framework.html
@@ -78,6 +78,7 @@
               ng-click="selectColumn('active_tasks', 'host')">
             Host
           </th>
+          <th></th>
         </tr>
       </thead>
       <tbody>
@@ -90,6 +91,11 @@
           <td>{{task.name}}</td>
           <td>{{task.state | truncateMesosState}}</td>
           <td>{{slaves[task.slave_id].hostname}}</td>
+          <td>
+            <a href="#/slaves/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/browse">
+              Sandbox
+            </a>
+          </td>
         </tr>
       </tbody>
     </table>
@@ -114,6 +120,8 @@
               ng-click="selectColumn('completed_tasks', 'host')">
             Host
           </th>
+          <th>
+          </th>
         </tr>
       </thead>
       <tbody>
@@ -126,6 +134,11 @@
               {{slaves[task.slave_id].hostname}}
             </a>
           </td>
+          <td>
+            <a href="#/slaves/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/browse">
+              Sandbox
+            </a>
+          </td>
         </tr>
       </tbody>
     </table>

http://git-wip-us.apache.org/repos/asf/mesos/blob/f6d95e89/src/webui/master/static/js/app.js
----------------------------------------------------------------------
diff --git a/src/webui/master/static/js/app.js b/src/webui/master/static/js/app.js
index d59e22c..92e8e2d 100644
--- a/src/webui/master/static/js/app.js
+++ b/src/webui/master/static/js/app.js
@@ -20,6 +20,18 @@
           {templateUrl: 'static/slave_framework.html', controller: 'SlaveFrameworkCtrl'})
         .when('/slaves/:slave_id/frameworks/:framework_id/executors/:executor_id',
           {templateUrl: 'static/slave_executor.html', controller: 'SlaveExecutorCtrl'})
+
+        // Use a non-falsy template so the controller will still be executed.
+        // Since the controller is intended only to redirect, the blank template
+        // is fine.
+        //
+        // By design, controllers currently will not handle routes if the
+        // template is falsy. There is an issue open in Angular to add that
+        // feature:
+        //
+        //     https://github.com/angular/angular.js/issues/1838
+        .when('/slaves/:slave_id/frameworks/:framework_id/executors/:executor_id/browse',
+          {template: ' ', controller: 'SlaveExecutorRerouterCtrl'})
         .when('/slaves/:slave_id/browse',
           {templateUrl: 'static/browse.html', controller: 'BrowseCtrl'})
         .otherwise({redirectTo: '/'});

http://git-wip-us.apache.org/repos/asf/mesos/blob/f6d95e89/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 c553e35..305aeaa 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -742,6 +742,78 @@
   });
 
 
+  // Reroutes a request like
+  // '/slaves/:slave_id/frameworks/:framework_id/executors/:executor_id/browse'
+  // to the executor's sandbox. This requires a second request because the
+  // directory to browse is known by the slave but not by the master. Request
+  // the directory from the slave, and then redirect to it.
+  //
+  // TODO(ssorallen): Add `executor.directory` to the state.json output so this
+  // controller of rerouting is no longer necessary.
+  mesosApp.controller('SlaveExecutorRerouterCtrl',
+      function($http, $location, $routeParams, $scope, $window) {
+
+    var pid = $scope.slaves[$routeParams.slave_id].pid;
+    var hostname = $scope.slaves[$routeParams.slave_id].hostname;
+    var id = pid.substring(0, pid.indexOf('@'));
+    var host = hostname + ":" + pid.substring(pid.lastIndexOf(':') + 1);
+
+    // Request slave details to get access to the route executor's "directory"
+    // to navigate directly to the executor's sandbox.
+    $http.jsonp('http://' + host + '/' + id + '/state.json?jsonp=JSON_CALLBACK')
+      .success(function(response) {
+
+        // TODO(ssorallen): Add error messaging on the following pageview should
+        // an error cause this function to be called.
+        function goBack() {
+          if ($window.history.length > 1) {
+            // If the browser has something in its history, just go back.
+            $window.history.back();
+          } else {
+            // Otherwise navigate to the framework page, which is likely the
+            // previous page anyway.
+            $location.path('/frameworks/' + $routeParms.framework_id).replace();
+          }
+        }
+
+        function matchFramework(framework) {
+          return $routeParams.framework_id === framework.id;
+        }
+
+        var framework =
+          _.find(response.frameworks, matchFramework) ||
+          _.find(response.completed_frameworks, matchFramework);
+
+        if (!framework) {
+          return goBack();
+        }
+
+        function matchExecutor(executor) {
+          return $routeParams.executor_id === executor.id;
+        }
+
+        var executor =
+          _.find(framework.executors, matchExecutor) ||
+          _.find(framework.completed_executors, matchExecutor);
+
+        if (!executor) {
+          return goBack();
+        }
+
+        // Navigate to a path like '/slaves/:id/browse?path=%2Ftmp%2F', the
+        // recognized "browse" endpoint for a slave.
+        $location.path('/slaves/' + $routeParams.slave_id + '/browse')
+          .search({path: executor.directory})
+          .replace();
+      })
+      .error(function(response) {
+        // Is the slave dead? Navigate home since returning to the slave might
+        // end up in an endless loop.
+        $location.path('/').replace();
+      });
+  });
+
+
   mesosApp.controller('BrowseCtrl', function($scope, $routeParams, $http) {
     setNavbarActiveTab('slaves');
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/f6d95e89/src/webui/master/static/slave_executor.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/slave_executor.html b/src/webui/master/static/slave_executor.html
index 1e43aff..519847c 100644
--- a/src/webui/master/static/slave_executor.html
+++ b/src/webui/master/static/slave_executor.html
@@ -149,7 +149,7 @@
               ng-click="selectColumn('tasks', 'resources.mem')">
             Mem (allocated)
           </th>
-          <th>Executor Sandbox</th>
+          <th></th>
         </tr>
       </thead>
       <tbody>
@@ -162,7 +162,7 @@
           <td>
             <a href="{{'#/slaves/' + slave_id + '/browse?path=' +
                        encodeURIComponent(executor.directory)}}">
-              browse
+              Sandbox
             </a>
           </td>
         </tr>
@@ -193,7 +193,7 @@
               ng-click="selectColumn('completed_tasks', 'resources.mem')">
             Mem (allocated)
           </th>
-          <th>Executor Sandbox</th>
+          <th></th>
         </tr>
       </thead>
       <tbody>
@@ -206,7 +206,7 @@
           <td>
             <a href="{{'#/slaves/' + slave_id + '/browse?path=' +
                        encodeURIComponent(executor.directory)}}">
-              browse
+              Sandbox
             </a>
           </td>
         </tr>

http://git-wip-us.apache.org/repos/asf/mesos/blob/f6d95e89/src/webui/master/static/slave_framework.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/slave_framework.html b/src/webui/master/static/slave_framework.html
index 63eb5c4..947bab1 100644
--- a/src/webui/master/static/slave_framework.html
+++ b/src/webui/master/static/slave_framework.html
@@ -103,7 +103,7 @@
               ng-click="selectColumn('executors', 'resources.mem')">
             Mem (Used / Allocated)
           </th>
-          <th>Sandbox</th>
+          <th></th>
         </tr>
       </thead>
 
@@ -125,7 +125,7 @@
           <td>
             <a href="{{'#/slaves/' + slave_id + '/browse?path=' +
                        encodeURIComponent(executor.directory)}}">
-              browse
+              Sandbox
             </a>
           </td>
         </tr>