Explorar el Código

AMBARI-4946. Installer wizard: Error handling for failed Start all services call. (jaimin)

Jaimin Jetly hace 11 años
padre
commit
5fca4800db

+ 33 - 5
ambari-web/app/controllers/wizard/step9_controller.js

@@ -80,6 +80,9 @@ App.WizardStep9Controller = Em.Controller.extend({
    */
   hostsWithHeartbeatLost: [],
 
+   // Flag is set in the start all services error callback function
+  startCallFailed: false,
+
   /*
    * Status of the page. Possible values: <info, warning, failed and success>.
    * This property is used in the step-9 view for displaying the appropriate color of the overall progress bar and
@@ -253,7 +256,9 @@ App.WizardStep9Controller = Em.Controller.extend({
    */
   updateStatus: function () {
     var status = 'info';
-    if (this.get('hosts').someProperty('status', 'failed') || this.get('hosts').someProperty('status', 'heartbeat_lost')) {
+    if (this.get('hosts').someProperty('status', 'failed')
+      || this.get('hosts').someProperty('status', 'heartbeat_lost')
+      || this.get('startCallFailed')) {
       status = 'failed';
     } else if (this.get('hosts').someProperty('status', 'warning')) {
       if (this.isStepFailed()) {
@@ -326,6 +331,7 @@ App.WizardStep9Controller = Em.Controller.extend({
   clearStep: function () {
     this.get('hosts').clear();
     this.set('hostsWithHeartbeatLost', []);
+    this.set('startCallFailed',false);
     this.set('status', 'info');
     this.set('progress', '0');
     this.set('numPolls', 1);
@@ -589,14 +595,36 @@ App.WizardStep9Controller = Em.Controller.extend({
   /**
    * Error callback function for start services task.
    */
-  launchStartServicesErrorCallback: function () {
+  launchStartServicesErrorCallback: function (jqXHR) {
     console.log("ERROR");
+    this.set('startCallFailed',true);
     var clusterStatus = {
-      status: 'START FAILED',
-      isStartError: true,
+      status: 'INSTALL FAILED',
+      isStartError: false,
       isCompleted: false
     };
-    App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
+    if (App.testMode) {
+      this.set('content.cluster', clusterStatus);
+    } else {
+      App.router.get(this.get('content.controllerName')).saveClusterStatus(clusterStatus);
+    }
+    this.get('hosts').forEach(function (host) {
+      host.set('progress', '100');
+    });
+    this.set('progress','100');
+
+    var params = {
+      cluster: this.get('content.cluster.name')
+    };
+
+    if (this.get('content.controllerName') === 'addHostController') {
+      params.name = 'wizard.step9.add_host.launch_start_services';
+    } else {
+      params.name = 'wizard.step9.installer.launch_start_services';
+    }
+
+    var opt = App.formatRequest.call(App.urls[params.name], params);
+    App.ajax.defaultErrorHandler(jqXHR,opt.url,opt.type);
   },
 
   /**

+ 1 - 0
ambari-web/app/messages.js

@@ -572,6 +572,7 @@ Em.I18n.translations = {
   'installer.step9.status.success':'Successfully installed and started the services.',
   'installer.step9.status.warning':'Installed and started the services with some warnings.',
   'installer.step9.status.failed':'Failed to install/start the services.',
+  'installer.step9.status.start.services.failed':'Start all services API call failed.',
   'installer.step9.status.install.components.failed': 'Some service components are still not known to have installed successfully. Please Retry',
   'installer.step9.status.hosts.heartbeat_lost': 'Ambari agent is not runnig on {0} host.',
   'installer.step9.host.heartbeat_lost': 'Heartbeat lost for the host',

+ 4 - 6
ambari-web/app/utils/ajax.js

@@ -1825,18 +1825,14 @@ var ajax = Em.Object.extend({
     method = method || 'GET';
     var self = this;
     var api = " received on " + method + " method for API: " + url;
-    var showMessage = true;
     try {
       var json = $.parseJSON(jqXHR.responseText);
       var message = json.message;
     } catch (err) {
     }
-    if (showStatus === null) {
+    if (!showStatus) {
       showStatus = 500;
     }
-    if (message === undefined) {
-      showMessage = false;
-    }
     var statusCode = jqXHR.status + " status code";
     if (jqXHR.status === showStatus && !this.modalPopup) {
       this.modalPopup = App.ModalPopup.show({
@@ -1852,7 +1848,7 @@ var ajax = Em.Object.extend({
           api: api,
           statusCode: statusCode,
           message: message,
-          showMessage: showMessage
+          showMessage: !!message
         })
       });
     }
@@ -1905,3 +1901,5 @@ if ($.mocho) {
 }
 
 App.ajax = ajax.create({});
+App.formatRequest = formatRequest;
+App.urls = urls;

+ 3 - 1
ambari-web/app/views/wizard/step9_view.js

@@ -65,6 +65,8 @@ App.WizardStep9View = Em.View.extend({
         // When present requests succeeds but some host components are in UNKNOWN or INSTALL_FAILED state and
         // hosts are in HEARTBEAT_LOST state
         this.set('resultMsg', Em.I18n.t('installer.step9.status.hosts.heartbeat_lost').format(this.get('controller.hostsWithHeartbeatLost').length));
+      } else if (this.get('controller.startCallFailed')) {
+        this.set('resultMsg', Em.I18n.t('installer.step9.status.start.services.failed'));
       } else {
         this.set('resultMsg', Em.I18n.t('installer.step9.status.failed'));
       }
@@ -74,7 +76,7 @@ App.WizardStep9View = Em.View.extend({
       this.set('resultMsg', Em.I18n.t('installer.step9.status.success'));
       this.set('resultMsgColor', 'alert-success');
     }
-  }.observes('controller.status', 'isHostHeartbeatLost'),
+  }.observes('controller.status', 'controller.startCallFailed','isHostHeartbeatLost'),
 
 
   hostWithInstallFailed: function (event, context) {

+ 44 - 1
ambari-web/test/installer/step9_test.js

@@ -1121,7 +1121,50 @@ describe('App.InstallerStep9Controller', function () {
         });
       });
     });
-
   })
 
+  // On completion of Start all services error callback function,
+  // Cluster Status should be INSTALL FAILED
+  // All progress bar on the screen should be finished (100%) with blue color.
+  // Retry button should be enabled, next button should be disabled
+
+  describe('#launchStartServicesErrorCallback', function () {
+    App.testMode = true;
+    // override the actual function
+    App.popup = {
+      setErrorPopup: function() {
+        return true;
+      }
+    };
+    var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}),Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
+    var controller = App.WizardStep9Controller.create({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING',name: 'c1'}},togglePreviousSteps: function(){}});
+
+    //Action
+    controller.launchStartServicesErrorCallback({status:500, statusTesxt: 'Server Error'});
+    it('Cluster Status should be INSTALL FAILED', function () {
+      expect(controller.get('content.cluster.status')).to.equal('INSTALL FAILED');
+    });
+
+    it('Main progress bar on the screen should be finished (100%) with red color', function () {
+      expect(controller.get('progress')).to.equal('100');
+      expect(controller.get('status')).to.equal('failed');
+    });
+
+    it('All Host progress bars on the screen should be finished (100%) with blue color', function () {
+      controller.get('hosts').forEach(function(host){
+        expect(host.get('progress')).to.equal('100');
+        expect(host.get('status')).to.equal('info');
+      });
+    });
+
+    it('Next button should be disabled', function () {
+      expect(controller.get('isSubmitDisabled')).to.equal(true);
+    });
+
+    it('Retry button should be visible', function () {
+      expect(controller.get('showRetry')).to.equal(true);
+    })
+
+  });
+
 });