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/14 19:00:08 UTC
[4/5] mesos git commit: Fixed the wrong sandbox directory of the
tasks in Web UI.
Fixed the wrong sandbox directory of the tasks in Web UI.
For the task launched by default-executor, its sandbox directory is
'executor_directory/tasks/task_id/'. This patch generates the
corresponding sandbox directory in Web UI for the task according to its
executor type.
Review: https://reviews.apache.org/r/52471/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6762fc8f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6762fc8f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6762fc8f
Branch: refs/heads/master
Commit: 6762fc8fb26470e3e24a915d4c19ceb2005fcce7
Parents: 88cd1df
Author: haosdent huang <ha...@gmail.com>
Authored: Fri Oct 14 11:59:44 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Oct 14 11:59:44 2016 -0700
----------------------------------------------------------------------
src/webui/master/static/agent_executor.html | 4 +-
src/webui/master/static/framework.html | 4 +-
src/webui/master/static/home.html | 6 +--
src/webui/master/static/js/app.js | 4 +-
src/webui/master/static/js/controllers.js | 60 +++++++++++++++++++++---
5 files changed, 63 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/6762fc8f/src/webui/master/static/agent_executor.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/agent_executor.html b/src/webui/master/static/agent_executor.html
index 8b83ed5..d2ab85d 100644
--- a/src/webui/master/static/agent_executor.html
+++ b/src/webui/master/static/agent_executor.html
@@ -147,7 +147,7 @@
<td>{{task.resources.disk * (1024 * 1024) | dataSize}}</td>
<td>
<a href="{{'#/agents/' + agent_id + '/browse?path=' +
- encodeURIComponent(executor.directory)}}">
+ encodeURIComponent(task.directory)}}">
Sandbox
</a>
</td>
@@ -180,7 +180,7 @@
<td>{{completed_task.resources.disk * (1024 * 1024) | dataSize}}</td>
<td>
<a href="{{'#/agents/' + agent_id + '/browse?path=' +
- encodeURIComponent(executor.directory)}}">
+ encodeURIComponent(completed_task.directory)}}">
Sandbox
</a>
</td>
http://git-wip-us.apache.org/repos/asf/mesos/blob/6762fc8f/src/webui/master/static/framework.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/framework.html b/src/webui/master/static/framework.html
index bc3c56a..6297cf9 100644
--- a/src/webui/master/static/framework.html
+++ b/src/webui/master/static/framework.html
@@ -84,7 +84,7 @@
</span>
</td>
<td>
- <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/browse">
+ <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/tasks/{{task.id}}/browse">
Sandbox
</a>
<span class="text-muted" data-ng-show="!agents[task.slave_id]">
@@ -129,7 +129,7 @@
</span>
</td>
<td>
- <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/browse">
+ <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/tasks/{{task.id}}/browse">
Sandbox
</a>
<span class="text-muted" data-ng-show="!agents[task.slave_id]">
http://git-wip-us.apache.org/repos/asf/mesos/blob/6762fc8f/src/webui/master/static/home.html
----------------------------------------------------------------------
diff --git a/src/webui/master/static/home.html b/src/webui/master/static/home.html
index 179cb15..07f862f 100644
--- a/src/webui/master/static/home.html
+++ b/src/webui/master/static/home.html
@@ -181,7 +181,7 @@
</span>
</td>
<td>
- <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/browse">
+ <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/tasks/{{task.id}}/browse">
Sandbox
</a>
<span class="text-muted" data-ng-show="!agents[task.slave_id]">
@@ -229,7 +229,7 @@
</span>
</td>
<td>
- <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/browse">
+ <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/tasks/{{task.id}}/browse">
Sandbox
</a>
<span class="text-muted" data-ng-show="!agents[task.slave_id]">
@@ -276,7 +276,7 @@
</span>
</td>
<td>
- <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/browse">
+ <a data-ng-show="agents[task.slave_id]" href="#/agents/{{task.slave_id}}/frameworks/{{task.framework_id}}/executors/{{task.executor_id}}/tasks/{{task.id}}/browse">
Sandbox
</a>
<span class="text-muted" data-ng-show="!agents[task.slave_id]">
http://git-wip-us.apache.org/repos/asf/mesos/blob/6762fc8f/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 400a428..c764430 100644
--- a/src/webui/master/static/js/app.js
+++ b/src/webui/master/static/js/app.js
@@ -40,7 +40,9 @@
//
// https://github.com/angular/angular.js/issues/1838
.when('/agents/:agent_id/frameworks/:framework_id/executors/:executor_id/browse',
- {template: ' ', controller: 'AgentExecutorRerouterCtrl'})
+ {template: ' ', controller: 'AgentTaskAndExecutorRerouterCtrl'})
+ .when('/agents/:agent_id/frameworks/:framework_id/executors/:executor_id/tasks/:task_id/browse',
+ {template: ' ', controller: 'AgentTaskAndExecutorRerouterCtrl'})
.when('/agents/:agent_id/browse',
{templateUrl: 'static/browse.html', controller: 'BrowseCtrl'})
http://git-wip-us.apache.org/repos/asf/mesos/blob/6762fc8f/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 29a5a1c..8aac466 100644
--- a/src/webui/master/static/js/controllers.js
+++ b/src/webui/master/static/js/controllers.js
@@ -49,6 +49,21 @@
}
}
+ // Set the task sandbox directory for use by the WebUI.
+ function setTaskSandbox(executor) {
+ _.each(
+ [executor.tasks, executor.queued_tasks, executor.completed_tasks],
+ function(tasks) {
+ _.each(tasks, function(task) {
+ if (executor.type === 'DEFAULT') {
+ task.directory = executor.directory + '/tasks/' + task.id;
+ } else {
+ task.directory = executor.directory;
+ };
+ });
+ });
+ }
+
// Update the outermost scope with the new state.
function updateState($scope, $timeout, state) {
@@ -705,6 +720,8 @@
return;
}
+ setTaskSandbox($scope.executor);
+
$('#agent').show();
})
.error(function (reason) {
@@ -722,15 +739,17 @@
}]);
- // Reroutes a request like
- // '/agents/:agent_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 agent but not by the master. Request
- // the directory from the agent, and then redirect to it.
+ // Reroutes requests like:
+ // * '/agents/:agent_id/frameworks/:framework_id/executors/:executor_id/browse'
+ // * '/agents/:agent_id/frameworks/:framework_id/executors/:executor_id/tasks/:task_id/browse'
+ // to the sandbox directory of the executor or the task respectively. This
+ // requires a second request because the directory to browse is known by the
+ // agent but not by the master. Request the directory from the agent, and then
+ // redirect to it.
//
// TODO(ssorallen): Add `executor.directory` to the master's state endpoint
// output so this controller of rerouting is no longer necessary.
- mesosApp.controller('AgentExecutorRerouterCtrl',
+ mesosApp.controller('AgentTaskAndExecutorRerouterCtrl',
function($alert, $http, $location, $routeParams, $scope, $window) {
function goBack(flashMessageOrOptions) {
@@ -809,10 +828,37 @@
);
}
+ var sandboxDirectory = executor.directory;
+
+ // Continue to navigate to the task's sandbox if the task id is
+ // specified in route parameters.
+ if ($routeParams.task_id) {
+ setTaskSandbox(executor);
+
+ function matchTask(task) {
+ return $routeParams.task_id === task.id;
+ }
+
+ var task =
+ _.find(executor.tasks, matchTask) ||
+ _.find(executor.queued_tasks, matchTask) ||
+ _.find(executor.completed_tasks, matchTask);
+
+ if (!task) {
+ return goBack(
+ "Task with ID '" + $routeParams.task_id +
+ "' does not exist on agent with ID '" + $routeParams.agent_id +
+ "'."
+ );
+ }
+
+ sandboxDirectory = task.directory;
+ }
+
// Navigate to a path like '/agents/:id/browse?path=%2Ftmp%2F', the
// recognized "browse" endpoint for an agent.
$location.path('/agents/' + $routeParams.agent_id + '/browse')
- .search({path: executor.directory})
+ .search({path: sandboxDirectory})
.replace();
})
.error(function(response) {