Browse Source

AMBARI-995. Deploy logs not shown for failed tasks. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1418914 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 years ago
parent
commit
d9bae744eb

+ 2 - 0
AMBARI-666-CHANGES.txt

@@ -448,6 +448,8 @@ AMBARI-666 branch (unreleased changes)
 
 
   BUG FIXES
   BUG FIXES
 
 
+  AMBARI-995. Deploy logs not shown for failed tasks. (yusaku)
+
   AMBARI-992. Logout does not clean application state properly. (yusaku)
   AMBARI-992. Logout does not clean application state properly. (yusaku)
 
 
   AMBARI-957. Adding a host whose hostname is the same as the one the user 
   AMBARI-957. Adding a host whose hostname is the same as the one the user 

+ 16 - 0
ambari-web/app/assets/data/wizard/deploy/poll_1.json

@@ -35,6 +35,22 @@
         "host_name" : "localhost.localdomain",
         "host_name" : "localhost.localdomain",
         "stage_id" : "1"
         "stage_id" : "1"
       }
       }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/3",
+      "Tasks" : {
+        "id" : "3",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "PENDING",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "SECONDARY_NAMENODE",
+        "stderr" : "",
+        "host_name" : "host2",
+        "stage_id" : "1"
+      }
     }
     }
   ]
   ]
 }
 }

+ 16 - 0
ambari-web/app/assets/data/wizard/deploy/poll_2.json

@@ -35,6 +35,22 @@
         "host_name" : "localhost.localdomain",
         "host_name" : "localhost.localdomain",
         "stage_id" : "1"
         "stage_id" : "1"
       }
       }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/3",
+      "Tasks" : {
+        "id" : "3",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "QUEUED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "SECONDARY_NAMENODE",
+        "stderr" : "",
+        "host_name" : "host2",
+        "stage_id" : "1"
+      }
     }
     }
   ]
   ]
 }
 }

+ 16 - 0
ambari-web/app/assets/data/wizard/deploy/poll_3.json

@@ -35,6 +35,22 @@
         "host_name" : "localhost.localdomain",
         "host_name" : "localhost.localdomain",
         "stage_id" : "1"
         "stage_id" : "1"
       }
       }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/3",
+      "Tasks" : {
+        "id" : "3",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "IN_PROGRESS",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "SECONDARY_NAMENODE",
+        "stderr" : "",
+        "host_name" : "host2",
+        "stage_id" : "1"
+      }
     }
     }
   ]
   ]
 }
 }

+ 16 - 0
ambari-web/app/assets/data/wizard/deploy/poll_4.json

@@ -35,6 +35,22 @@
         "host_name" : "localhost.localdomain",
         "host_name" : "localhost.localdomain",
         "stage_id" : "1"
         "stage_id" : "1"
       }
       }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/3",
+      "Tasks" : {
+        "id" : "3",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "IN_PROGRESS",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "SECONDARY_NAMENODE",
+        "stderr" : "",
+        "host_name" : "host2",
+        "stage_id" : "1"
+      }
     }
     }
   ]
   ]
 }
 }

+ 16 - 0
ambari-web/app/assets/data/wizard/deploy/poll_5.json

@@ -35,6 +35,22 @@
         "host_name" : "localhost.localdomain",
         "host_name" : "localhost.localdomain",
         "stage_id" : "1"
         "stage_id" : "1"
       }
       }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/3",
+      "Tasks" : {
+        "id" : "3",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "SECONDARY_NAMENODE",
+        "stderr" : "",
+        "host_name" : "host2",
+        "stage_id" : "1"
+      }
     }
     }
   ]
   ]
 }
 }

+ 16 - 0
ambari-web/app/assets/data/wizard/deploy/poll_5_failed.json

@@ -36,6 +36,22 @@
         "stage_id" : "1",
         "stage_id" : "1",
         "sf" : "100"
         "sf" : "100"
       }
       }
+    },
+    {
+      "href" : "http://localhost:8080/api/clusters/mycluster/requests/1/tasks/3",
+      "Tasks" : {
+        "id" : "3",
+        "attempt_cnt" : "0",
+        "exit_code" : "999",
+        "stdout" : "",
+        "status" : "COMPLETED",
+        "command" : "INSTALL",
+        "start_time" : "-1",
+        "role" : "SECONDARY_NAMENODE",
+        "stderr" : "",
+        "host_name" : "host2",
+        "stage_id" : "1"
+      }
     }
     }
   ]
   ]
 }
 }

+ 9 - 17
ambari-web/app/controllers/wizard/step9_controller.js

@@ -105,7 +105,7 @@ App.WizardStep9Controller = Em.Controller.extend({
   },
   },
 
 
   replacePolledData: function (polledData) {
   replacePolledData: function (polledData) {
-    this.polledData.clear;
+    this.polledData.clear();
     this.set('polledData', polledData);
     this.set('polledData', polledData);
   },
   },
 
 
@@ -168,7 +168,7 @@ App.WizardStep9Controller = Em.Controller.extend({
       case 'EXECUTE' :
       case 'EXECUTE' :
         switch (task.status) {
         switch (task.status) {
           case 'PENDING':
           case 'PENDING':
-            return 'Preparing to execute' + role;
+            return 'Preparing to execute ' + role;
           case 'QUEUED' :
           case 'QUEUED' :
             return role + ' is queued for execution';
             return role + ' is queued for execution';
           case 'IN_PROGRESS':
           case 'IN_PROGRESS':
@@ -256,7 +256,7 @@ App.WizardStep9Controller = Em.Controller.extend({
   },
   },
 
 
   onWarningPerHost: function (actions, contentHost) {
   onWarningPerHost: function (actions, contentHost) {
-    if (actions.findProperty('Tasks.status', 'FAILED') || actions.findProperty('Tasks.status', 'ABORTED') || actions.findProperty('Tasks.status', 'TIMEDOUT')) {
+    if (actions.someProperty('Tasks.status', 'FAILED') || actions.someProperty('Tasks.status', 'ABORTED') || actions.someProperty('Tasks.status', 'TIMEDOUT')) {
       console.log('step9: In warning');
       console.log('step9: In warning');
       contentHost.set('status', 'warning');
       contentHost.set('status', 'warning');
       this.set('status', 'warning');
       this.set('status', 'warning');
@@ -413,15 +413,6 @@ App.WizardStep9Controller = Em.Controller.extend({
     return false;
     return false;
   },
   },
 
 
-  getCompletedTasksForHost: function (host) {
-    var hostname = host.get('name');
-    var tasksPerHost = host.logTasks.filterProperty('Tasks.host_name', hostname);
-    var succededTasks = tasksPerHost.filterProperty('Tasks.status', 'COMPLETED');
-    var inProgressTasks = tasksPerHost.filterProperty('Tasks.status', 'IN_PROGRESS');
-    var listedTasksPerHost = succededTasks.concat(inProgressTasks).uniq();
-    return listedTasksPerHost;
-  },
-
   setTasksPerHost: function () {
   setTasksPerHost: function () {
     console.log("In setTasksPerHost fo step9*****************");
     console.log("In setTasksPerHost fo step9*****************");
     var tasksData = this.get('polledData');
     var tasksData = this.get('polledData');
@@ -446,13 +437,14 @@ App.WizardStep9Controller = Em.Controller.extend({
   setLogTasksStatePerHost: function (tasksPerHost, host) {
   setLogTasksStatePerHost: function (tasksPerHost, host) {
     var tasks = [];
     var tasks = [];
     console.log('In step9 setTasksStatePerHost function.');
     console.log('In step9 setTasksStatePerHost function.');
-    tasksPerHost.forEach(function (_taskPerHost) {
+    tasksPerHost.forEach(function (_task) {
       console.log('In step9 _taskPerHost function.');
       console.log('In step9 _taskPerHost function.');
-      if (_taskPerHost.Tasks.status !== 'PENDING' && _taskPerHost.Tasks.status !== 'QUEUED') {
-        var task = host.logTasks.findProperty('Tasks.id', _taskPerHost.Tasks.id);
-        if (!(task && (task.Tasks.command === _taskPerHost.Tasks.command))) {
-          host.logTasks.pushObject(_taskPerHost);
+      if (_task.Tasks.status !== 'PENDING' && _task.Tasks.status !== 'QUEUED') {
+        var task = host.logTasks.findProperty('Tasks.id', _task.Tasks.id);
+        if (task) {
+          host.logTasks.removeObject(task);
         }
         }
+        host.logTasks.pushObject(_task);
       }
       }
     }, this);
     }, this);
   },
   },

+ 1 - 1
ambari-web/app/templates/wizard/step9HostTasksLogPopup.hbs

@@ -3,7 +3,7 @@
   {{#each role in view.roles}}
   {{#each role in view.roles}}
     {{#each taskInfo in role.taskInfos}}
     {{#each taskInfo in role.taskInfos}}
     <div>
     <div>
-      <a href="#" {{action toggleTaskLog taskInfo}}>{{#if taskInfo.isLogHidden}}Show{{else}}Hide{{/if}} {{role.roleName}} {{taskInfo.status}} log</a>
+      <a href="#" {{action toggleTaskLog taskInfo}}>{{#if taskInfo.isLogHidden}}Show{{else}}Hide{{/if}} {{role.roleName}} {{taskInfo.command}} log ({{taskInfo.status}})</a>
       <div {{bindAttr class="taskInfo.isLogHidden:hidden"}}>
       <div {{bindAttr class="taskInfo.isLogHidden:hidden"}}>
         <h5>stderr:</h5>
         <h5>stderr:</h5>
         <pre class="stderr">{{taskInfo.stderr}}</pre>
         <pre class="stderr">{{taskInfo.stderr}}</pre>

+ 13 - 0
ambari-web/app/utils/helper.js

@@ -234,5 +234,18 @@ App.format = {
       case 'DECOMMISSION_DATANODE':
       case 'DECOMMISSION_DATANODE':
         return 'Decommission DataNode';
         return 'Decommission DataNode';
     }
     }
+  },
+
+  /**
+   * PENDING - Not queued yet for a host
+   * QUEUED - Queued for a host
+   * IN_PROGRESS - Host reported it is working
+   * COMPLETED - Host reported success
+   * FAILED - Failed
+   * TIMEDOUT - Host did not respond in time
+   * ABORTED - Operation was abandoned
+   */
+  taskStatus: function(_taskStatus) {
+    return _taskStatus.replace('_', ' ').toLowerCase();
   }
   }
 };
 };

+ 14 - 6
ambari-web/app/views/wizard/step9_view.js

@@ -127,22 +127,23 @@ App.HostStatusView = Em.View.extend({
           return this.get('parentView.obj');
           return this.get('parentView.obj');
         }.property('parentView.obj'),
         }.property('parentView.obj'),
 
 
-        logTasks: [],  // initialized in didInsertElement
+        startedTasks: [],  // initialized in didInsertElement
 
 
         task: null, // set in showTaskLog; contains task info including stdout and stderr
         task: null, // set in showTaskLog; contains task info including stdout and stderr
 
 
         roles: function () {
         roles: function () {
           var roleArr = [];
           var roleArr = [];
-          var tasks = this.get('logTasks');
+          var tasks = this.get('startedTasks');
           if (tasks.length) {
           if (tasks.length) {
-            var _roles = this.get('logTasks').mapProperty('Tasks.role').uniq();
+            var _roles = tasks.mapProperty('Tasks.role').uniq();
             _roles.forEach(function (_role) {
             _roles.forEach(function (_role) {
               var taskInfos = [];
               var taskInfos = [];
               var roleObj = {};
               var roleObj = {};
               roleObj.roleName = App.format.role(_role);
               roleObj.roleName = App.format.role(_role);
               tasks.filterProperty('Tasks.role', _role).forEach(function (_task) {
               tasks.filterProperty('Tasks.role', _role).forEach(function (_task) {
                 var taskInfo = Ember.Object.create();
                 var taskInfo = Ember.Object.create();
-                taskInfo.set('status', _task.Tasks.command.toLowerCase());
+                taskInfo.set('command', _task.Tasks.command.toLowerCase());
+                taskInfo.set('status', App.format.taskStatus(_task.Tasks.status));
                 taskInfo.set('url', _task.href);
                 taskInfo.set('url', _task.href);
                 taskInfo.set('isLogHidden', true);
                 taskInfo.set('isLogHidden', true);
                 taskInfos.pushObject(taskInfo);
                 taskInfos.pushObject(taskInfo);
@@ -152,11 +153,18 @@ App.HostStatusView = Em.View.extend({
             }, this);
             }, this);
           }
           }
           return roleArr;
           return roleArr;
-        }.property('logTasks.@each'),
+        }.property('startedTasks.@each'),
 
 
         didInsertElement: function () {
         didInsertElement: function () {
           console.log('The value of event context is: ' + host.name);
           console.log('The value of event context is: ' + host.name);
-          this.set('logTasks', self.get('controller').getCompletedTasksForHost(host));
+          this.set('startedTasks', this.getStartedTasks(host));
+        },
+
+        getStartedTasks: function (host) {
+          var startedTasks = host.logTasks.filter(function (task) {
+            return task.Tasks.status != 'PENDING' && task.Tasks.status != 'QUEUED';
+          });
+          return startedTasks;
         },
         },
 
 
         toggleTaskLog: function (event, context) {
         toggleTaskLog: function (event, context) {