浏览代码

AMBARI-9724. Kerberos Wizard: Retry link doesn't work on step6. (akovalenko)

Aleksandr Kovalenko 10 年之前
父节点
当前提交
a1d0aac603

+ 20 - 4
ambari-web/app/controllers/main/admin/kerberos/step6_controller.js

@@ -30,8 +30,13 @@ App.KerberosWizardStep6Controller = App.KerberosProgressPageController.extend({
    */
   isBackButtonDisabled: true,
 
-  setRequest: function () {
-    this.set('request', {
+  /**
+   * Start cluster kerberization. On retry just unkerberize and kerbrize cluster.
+   * @param {bool} isRetry
+   */
+  setRequest: function (isRetry) {
+    var self = this;
+    var kerberizeRequest = {
       name: 'KERBERIZE_CLUSTER',
       ajaxName: 'admin.kerberize.cluster',
       ajaxData: {
@@ -41,7 +46,18 @@ App.KerberosWizardStep6Controller = App.KerberosProgressPageController.extend({
           }
         }
       }
-    });
+    };
+    if (isRetry) {
+      // on retry we have to unkerberize cluster
+      this.unkerberizeCluster().always(function() {
+        // clear current request object before start of kerberize process
+        self.set('request', kerberizeRequest);
+        self.clearStage();
+        self.loadStep();
+      });
+    } else {
+      this.set('request', kerberizeRequest);
+    }
   },
 
   /**
@@ -106,4 +122,4 @@ App.KerberosWizardStep6Controller = App.KerberosProgressPageController.extend({
       this.set('isBackButtonDisabled', true);
     }
   }.observes('tasks.@each.status')
-});
+});

+ 23 - 3
ambari-web/app/mixins/wizard/wizardProgressPageController.js

@@ -55,6 +55,7 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
   tasksMessagesPrefix: '',
 
   loadStep: function () {
+    this.clearStep();
     var self = this;
     if (!self.isSingleRequestPage) {
       this.initStep();
@@ -83,7 +84,6 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
   },
 
   initStep: function () {
-    this.clearStep();
     this.initializeTasks();
     if (!this.isSingleRequestPage) {
       this.loadTasks();
@@ -111,6 +111,19 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
     this.set('isLoaded', false);
   },
 
+  /**
+   * Clear stages info for single page request.
+   */
+  clearStage: function() {
+    this.setDBProperty('tasksRequestIds', null);
+    this.setDBProperty('tasksStatuses', null);
+    this.set('showRetry', false);
+    this.set('content.tasksRequestIds', null);
+    this.set('content.tasksStatuses', null);
+    this.set('content.currentTaskId', null);
+    this.get('stages').clear();
+  },
+
   retry: function () {
     this.set('showRetry', false);
     this.get('tasks').setEach('status','PENDING');
@@ -157,6 +170,9 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
   },
 
   updatePageWithPolledData: function(data) {
+    // If all tasks completed no need to update each task status.
+    // Preferable to skip polling of data for completed tasks after page refresh.
+    if (this.get('status') === 'COMPLETED') return;
     var self = this;
     var tasks = [];
     var currentPageRequestId = this.get('currentPageRequestId');
@@ -186,7 +202,8 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
       this.get('tasks').findProperty('id', currentTaskId).set('progress', progress);
     }
 
-    if (!(this.get('status') === 'COMPLETED')) {
+    // start polling if current step status not completed or failed
+    if (!(this.get('status') === 'COMPLETED' && this.get('status') === 'FAILED')) {
       window.setTimeout(function () {
         self.doPollingForPageRequest();
       }, self.POLL_INTERVAL);
@@ -198,10 +215,13 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
     var commands = this.isSingleRequestPage ? this.get('stages') : this.get('commands');
     var currentStep = App.router.get(this.get('content.controllerName') + '.currentStep');
     var tasksMessagesPrefix = this.get('tasksMessagesPrefix');
+    // check that all stages have been completed for single request type
+    var allStagesCompleted = commands.everyProperty('status', 'COMPLETED');
     for (var i = 0; i < commands.length; i++) {
       this.get('tasks').pushObject(Ember.Object.create({
         title: self.isSingleRequestPage ? commands[i].get('context') : Em.I18n.t(tasksMessagesPrefix + currentStep + '.task' + i + '.title'),
-        status: 'PENDING',
+        // set COMPLETED status for task if all stages completed successfully
+        status: allStagesCompleted ? 'COMPLETED' : 'PENDING',
         id: i,
         stageId: self.isSingleRequestPage ? commands[i].get('stage_id') : null,
         command: self.isSingleRequestPage ? 'k' : commands[i],

+ 3 - 5
ambari-web/app/routes/add_kerberos_routes.js

@@ -254,6 +254,7 @@ module.exports = App.WizardRoute.extend({
         if (result === 'error' && data.status === 409) {
           step6Controller.putKerberosDescriptor(kerberosDescriptor).always(function (data) {
             step6Controller.unkerberizeCluster().always(function (data) {
+              step6Controller.clearStage();
               router.transitionTo('step6');
             });
           });
@@ -279,11 +280,8 @@ module.exports = App.WizardRoute.extend({
         controller.connectOutlet('kerberosWizardStep6', controller.get('content'));
       });
     },
-    retry: function () {
-      var router = App.get('router');
-      var stepController = router.get('kerberosWizardStep6Controller');
-      stepController.setRequest();
-      stepController.loadStep();
+    retry: function (router) {
+      router.get('kerberosWizardStep6Controller').setRequest(true);
     },
     unroutePath: function () {
       return false;

+ 2 - 2
ambari-web/app/views/main/admin/kerberos/step5_view.js

@@ -26,5 +26,5 @@ App.KerberosWizardStep5View = App.KerberosProgressPageView.extend({
 
   submitButtonText: Em.I18n.t('common.next') + '&rarr;',
 
-  showBackButton: false
-});
+  showBackButton: true
+});