tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prak...@apache.org
Subject tez git commit: TEZ-2554. Tez UI: View log link does not correctly propagate login crendential to read log from yarn web. (sree via prakash)
Date Tue, 16 Jun 2015 13:27:38 GMT
Repository: tez
Updated Branches:
  refs/heads/master 7f51852b6 -> 6ae49e99d


TEZ-2554. Tez UI: View log link does not correctly propagate login crendential to read log
from yarn web. (sree via prakash)


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

Branch: refs/heads/master
Commit: 6ae49e99d3c9aadeea76c7497d1e186d19284f8a
Parents: 7f51852
Author: Prakash Ramachandran <pramachandran@hortonworks.com>
Authored: Tue Jun 16 18:52:04 2015 +0530
Committer: Prakash Ramachandran <pramachandran@hortonworks.com>
Committed: Tue Jun 16 18:56:11 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../controllers/dag-task-attempts-controller.js | 18 ++---
 .../app/scripts/controllers/dag_controller.js   |  1 +
 .../webapp/app/scripts/controllers/dag_tasks.js | 23 ++----
 .../app/scripts/controllers/task_controller.js  |  6 +-
 .../task_task_attempts_controller.js            | 18 ++---
 .../scripts/controllers/vertex_controller.js    |  6 ++
 .../vertex_task_attempts_controller.js          | 18 ++---
 .../controllers/vertex_tasks_controller.js      | 23 ++----
 .../src/main/webapp/app/scripts/helpers/misc.js | 76 ++++++++++++++++++++
 .../app/scripts/models/TimelineRestAdapter.js   |  2 +
 .../src/main/webapp/app/scripts/models/dag.js   |  5 ++
 .../components/basic-table/logs-cell.hbs        |  2 +-
 13 files changed, 122 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 335b382..1d5d095 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -37,6 +37,7 @@ Release 0.7.1: Unreleased
 INCOMPATIBLE CHANGES
 
 ALL CHANGES:
+  TEZ-2554. Tez UI: View log link does not correctly propagate login crendential to read
log from yarn web.
   TEZ-2548. TezClient submitDAG can hang if the AM is in the process of shutting down.
   TEZ-2547. Tez UI: Download Data fails on secure, cross-origin clusters
   TEZ-1961. Remove misleading exception "No running dag" from AM logs.

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
b/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
index 572e226..ce8f4e9 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
@@ -195,21 +195,13 @@ App.DagTaskAttemptsController = App.TablePageController.extend({
         templateName: 'components/basic-table/logs-cell',
         searchAndSortable: false,
         getCellContent: function(row) {
-          var yarnAppState = that.get('controllers.dag.yarnAppState'),
-              suffix = "/syslog_" + row.get('id'),
-              link = row.get('inProgressLog') || row.get('completedLog'),
-              cellContent = {};
-
-          if(link) {
-            cellContent.viewUrl = link + suffix;
-          }
-          link = row.get('completedLog');
-          if (link && yarnAppState === 'FINISHED' || yarnAppState === 'KILLED' ||
yarnAppState === 'FAILED') {
-            cellContent.downloadUrl = link + suffix;
-          }
+          var cellContent = App.Helpers.misc.constructLogLinks(
+                row,
+                that.get('controllers.dag.yarnAppState'),
+                that.get('controllers.dag.tezApp.user')
+              );
 
           cellContent.notAvailable = cellContent.viewUrl || cellContent.downloadUrl;
-
           return cellContent;
         }
       }

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/dag_controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/dag_controller.js b/tez-ui/src/main/webapp/app/scripts/controllers/dag_controller.js
index cef1827..96e707f 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/dag_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/dag_controller.js
@@ -56,6 +56,7 @@ App.DagController = Em.ObjectController.extend(App.Helpers.DisplayHelper,
{
       }).catch(function(){});
 
     loaders.push(appDetailLoader);
+    loaders.push(tezAppLoader);
 
     Em.RSVP.allSettled(loaders).then(function(){
       that.set('loading', false);

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js b/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
index 604899b..c3df785 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
@@ -60,26 +60,13 @@ App.DagTasksController = App.TablePageController.extend({
         vertexIdToNameMap = this.get('controllers.dag.vertexIdToNameMap') || {};
 
     function getLogContent(attempt) {
-      var yarnAppState = that.get('controllers.dag.yarnAppState'),
-          suffix,
-          link,
-          cellContent = {};
-
-      if(attempt) {
-        suffix = "/syslog_" + attempt.get('id'),
-        link = attempt.get('inProgressLog') || attempt.get('completedLog');
-
-        if(link) {
-          cellContent.viewUrl = link + suffix;
-        }
-        link = attempt.get('completedLog');
-        if (link && yarnAppState === 'FINISHED' || yarnAppState === 'KILLED' || yarnAppState
=== 'FAILED') {
-          cellContent.downloadUrl = link + suffix;
-        }
-      }
+      var cellContent = App.Helpers.misc.constructLogLinks(
+            attempt,
+            that.get('controllers.dag.yarnAppState'),
+            that.get('controllers.dag.tezApp.user')
+          );
 
       cellContent.notAvailable = cellContent.viewUrl || cellContent.downloadUrl;
-
       return cellContent;
     }
 

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js b/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
index 7f5afb1..b95620a 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
@@ -25,18 +25,22 @@ App.TaskController = Em.ObjectController.extend(App.Helpers.DisplayHelper,
App.M
 
   loadAdditional: function(task) {
     var that = this;
+    var applicationId = App.Helpers.misc.getAppIdFromVertexId(task.get('vertexID'));
 
     var dagLoader = this.store.find('dag', task.get('dagID'));
     var vertexLoader = this.store.find('vertex', task.get('vertexID'));
+    var tezAppLoader = this.store.find('tezApp', 'tez_' + applicationId);
 
     var allLoaders = Em.RSVP.hash({
       dag: dagLoader,
-      vertex: vertexLoader
+      vertex: vertexLoader,
+      tezApp: tezAppLoader
     });
 
     allLoaders.then(function(results) {
       task.set('vertex', results.vertex);
       task.set('vertex.dag', results.dag);
+      task.set('tezApp', results.tezApp);
     }).finally(function() {
       that.set('loading', false);
     });

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
b/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
index 8e491a1..75bd4c8 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
@@ -160,21 +160,13 @@ App.TaskAttemptsController = App.TablePageController.extend(App.AutoCounterColum
         templateName: 'components/basic-table/logs-cell',
         searchAndSortable: false,
         getCellContent: function(row) {
-          var yarnAppState = that.get('yarnAppState'),
-              suffix = "/syslog_" + row.get('id'),
-              link = row.get('inProgressLog') || row.get('completedLog'),
-              cellContent = {};
-
-          if(link) {
-            cellContent.viewUrl = link + suffix;
-          }
-          link = row.get('completedLog');
-          if (link && yarnAppState === 'FINISHED' || yarnAppState === 'KILLED' ||
yarnAppState === 'FAILED') {
-            cellContent.downloadUrl = link + suffix;
-          }
+          var cellContent = App.Helpers.misc.constructLogLinks(
+                row,
+                that.get('yarnAppState'),
+                that.get('controllers.task.tezApp.user')
+              );
 
           cellContent.notAvailable = cellContent.viewUrl || cellContent.downloadUrl;
-
           return cellContent;
         }
       }

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
index ad67842..a4ba6e1 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
@@ -55,6 +55,12 @@ App.VertexController = Em.ObjectController.extend(App.Helpers.DisplayHelper,
App
     }).catch(function(){});
     loaders.push(appDetailFetcher);
 
+    var tezAppLoader = this.store.find('tezApp', 'tez_' + applicationId)
+      .then(function(app){
+        vertex.set('tezApp', app);
+      }).catch(function(){});
+    loaders.push(tezAppLoader);
+
     var dagFetcher = that.store.find('dag', vertex.get('dagID')).then(function (dag) {
       vertex.set('dag', dag);
     });

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
index c4a52f5..df714d0 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
@@ -178,21 +178,13 @@ App.VertexTaskAttemptsController = App.TablePageController.extend(App.AutoCounte
         templateName: 'components/basic-table/logs-cell',
         searchAndSortable: false,
         getCellContent: function(row) {
-          var yarnAppState = that.get('controllers.vertex.yarnAppState'),
-              suffix = "/syslog_" + row.get('id'),
-              link = row.get('inProgressLog') || row.get('completedLog'),
-              cellContent = {};
-
-          if(link) {
-            cellContent.viewUrl = link + suffix;
-          }
-          link = row.get('completedLog');
-          if (link && yarnAppState === 'FINISHED' || yarnAppState === 'KILLED' ||
yarnAppState === 'FAILED') {
-            cellContent.downloadUrl = link + suffix;
-          }
+          var cellContent = App.Helpers.misc.constructLogLinks(
+                row,
+                that.get('controllers.vertex.yarnAppState'),
+                that.get('controllers.vertex.tezApp.user')
+              );
 
           cellContent.notAvailable = cellContent.viewUrl || cellContent.downloadUrl;
-
           return cellContent;
         }
       }

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
index 4735eac..4574050 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
@@ -60,26 +60,13 @@ App.VertexTasksController = App.TablePageController.extend(App.AutoCounterColumn
     var that = this;
 
     function getLogContent(attempt) {
-      var yarnAppState = that.get('controllers.vertex.yarnAppState'),
-          suffix,
-          link,
-          cellContent = {};
-
-      if(attempt) {
-        suffix = "/syslog_" + attempt.get('id'),
-        link = attempt.get('inProgressLog') || attempt.get('completedLog');
-
-        if(link) {
-          cellContent.viewUrl = link + suffix;
-        }
-        link = attempt.get('completedLog');
-        if (link && yarnAppState === 'FINISHED' || yarnAppState === 'KILLED' || yarnAppState
=== 'FAILED') {
-          cellContent.downloadUrl = link + suffix;
-        }
-      }
+      var cellContent = App.Helpers.misc.constructLogLinks(
+            attempt,
+            that.get('controllers.vertex.yarnAppState'),
+            that.get('controllers.vertex.tezApp.user')
+          );
 
       cellContent.notAvailable = cellContent.viewUrl || cellContent.downloadUrl;
-
       return cellContent;
     }
 

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/misc.js b/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
index 8360af0..6decc3f 100644
--- a/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
+++ b/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
@@ -532,6 +532,82 @@ App.Helpers.misc = {
     return uniqueArray;
   },
 
+  /*
+   * Extends the path and adds new query params into an url
+   * @param url {String} Url to modify
+   * @param path {String} Path to be added
+   * @param queryParams {Object} Params to be added
+   * @return modified path
+   */
+  modifyUrl: function (url, path, queryParams) {
+    var urlParts = url.split('?'),
+        params = {};
+
+    if(queryParams) {
+      if(urlParts[1]) {
+        params = urlParts[1].split('&').reduce(function (obj, param) {
+          var paramParts;
+          if(param.trim()) {
+            paramParts = param.split('=');
+            obj[paramParts[0]] = paramParts[1];
+          }
+          return obj;
+        }, {});
+      }
+
+      params = $.extend(params, queryParams);
+
+      queryParams = [];
+      $.map(params, function (val, key) {
+        queryParams.push(key + "=" + val);
+      });
+
+      urlParts[1] = queryParams.join('&');
+    }
+
+    urlParts[0] += path || '';
+
+    return urlParts[1] ? '%@?%@'.fmt(urlParts[0], urlParts[1]) : urlParts[0];
+  },
+
+  constructLogLinks: function (attempt, yarnAppState, amUser) {
+    var path,
+        link,
+        logLinks = {},
+        params = amUser ? {
+          "user.name": amUser
+        } : {};
+
+    if(attempt) {
+      link = attempt.get('inProgressLog') || attempt.get('completedLog');
+      if(link) {
+        if(!link.match("/syslog_")) {
+          path = "/syslog_" + attempt.get('id');
+          if(amUser) {
+            path += "/" + amUser;
+          }
+        }
+        logLinks.viewUrl = App.Helpers.misc.modifyUrl(link, path, params);
+      }
+
+      link = attempt.get('completedLog');
+      if (link && yarnAppState === 'FINISHED' || yarnAppState === 'KILLED' || yarnAppState
=== 'FAILED') {
+        params["start"] = "0";
+
+        if(!link.match("/syslog_")) {
+          path = "/syslog_" + attempt.get('id');
+          if(amUser) {
+            path += "/" + amUser;
+          }
+        }
+
+        logLinks.downloadUrl = App.Helpers.misc.modifyUrl(link, path, params);
+      }
+    }
+
+    return logLinks;
+  },
+
   timelinePathForType: (function () {
     var typeToPathMap = {
       dag: 'TEZ_DAG_ID',

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js b/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
index 9e6f013..8f836cc 100644
--- a/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
+++ b/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
@@ -444,6 +444,8 @@ var timelineJsonToTezAppMap = {
   startedTime: 'startedTime',
   domain: 'domain',
 
+  user: 'primaryfilters.user.0',
+
   dags: 'relatedentities.TEZ_DAG_ID',
   configs: 'configs'
 };

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/scripts/models/dag.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/models/dag.js b/tez-ui/src/main/webapp/app/scripts/models/dag.js
index 08dfb48..7cfbc1b 100644
--- a/tez-ui/src/main/webapp/app/scripts/models/dag.js
+++ b/tez-ui/src/main/webapp/app/scripts/models/dag.js
@@ -124,6 +124,8 @@ App.Vertex = App.AbstractEntity.extend({
     return this.get('dagID').split('_').splice(-1).pop();
   }.property('dagID'),
 
+  tezApp: DS.belongsTo('tezApp'),
+
   /**
    * State of this vertex. Should be one of constants defined in
    * App.VertexState.
@@ -322,6 +324,7 @@ App.TezApp = App.AbstractEntity.extend({
   appId: DS.attr('string'),
   entityType: DS.attr('string'),
   domain: DS.attr('string'),
+  user: DS.attr('string'),
 
   startedTime: DS.attr('number'),
 
@@ -350,6 +353,8 @@ App.Task = App.AbstractEntity.extend({
   vertex: DS.belongsTo('vertex'),
   vertexID: DS.attr('string'),
 
+  tezApp: DS.belongsTo('tezApp'),
+
   startTime: DS.attr('number'),
 
   endTime: DS.attr('number'),

http://git-wip-us.apache.org/repos/asf/tez/blob/6ae49e99/tez-ui/src/main/webapp/app/templates/components/basic-table/logs-cell.hbs
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/templates/components/basic-table/logs-cell.hbs b/tez-ui/src/main/webapp/app/templates/components/basic-table/logs-cell.hbs
index a4ab4a1..4745d78 100644
--- a/tez-ui/src/main/webapp/app/templates/components/basic-table/logs-cell.hbs
+++ b/tez-ui/src/main/webapp/app/templates/components/basic-table/logs-cell.hbs
@@ -24,7 +24,7 @@
     &nbsp;
   {{/if}}
   {{#if view.cellContent.downloadUrl}}
-    <a target="_blank" href="{{unbound view.cellContent.downloadUrl}}?start=0" download
type="application/octet-stream">Download</a>
+    <a target="_blank" href="{{unbound view.cellContent.downloadUrl}}" download type="application/octet-stream">Download</a>
   {{else}}{{#unless view.cellContent.viewUrl}}
     <span class="message">Not Available!</span>
   {{/unless}}{{/if}}


Mime
View raw message