Browse Source

AMBARI-15369. Ambari cannot enable NN HA in kerberos env (alexantonenko)

Alex Antonenko 9 years ago
parent
commit
977cb4bc9f

+ 1 - 1
ambari-web/app/controllers/main/admin/highAvailability/hawq/activateStandby/step3_controller.js

@@ -106,7 +106,7 @@ App.ActivateHawqStandbyWizardStep3Controller = App.HighAvailabilityProgressPageC
 
 
   installHawqMaster: function () {
   installHawqMaster: function () {
     var hostName = this.get('content.hawqHosts.hawqStandby');
     var hostName = this.get('content.hawqHosts.hawqStandby');
-    this.createComponent(this.hawqMasterComponentName, hostName, this.hawqServiceName);
+    this.createInstallComponentTask(this.hawqMasterComponentName, hostName, this.hawqServiceName);
   },
   },
 
 
   deleteOldHawqMaster: function () {
   deleteOldHawqMaster: function () {

+ 1 - 1
ambari-web/app/controllers/main/admin/highAvailability/hawq/addStandby/step4_controller.js

@@ -36,7 +36,7 @@ App.AddHawqStandbyWizardStep4Controller = App.HighAvailabilityProgressPageContro
 
 
   installHawqStandbyMaster: function () {
   installHawqStandbyMaster: function () {
     var hostName = this.get('content.hawqHosts.newHawqStandby');
     var hostName = this.get('content.hawqHosts.newHawqStandby');
-    this.createComponent('HAWQSTANDBY', hostName, "HAWQ");
+    this.createInstallComponentTask('HAWQSTANDBY', hostName, "HAWQ");
   },
   },
 
 
   reconfigureHAWQ: function () {
   reconfigureHAWQ: function () {

+ 3 - 4
ambari-web/app/controllers/main/admin/highAvailability/nameNode/step5_controller.js

@@ -29,12 +29,12 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont
 
 
   installNameNode: function () {
   installNameNode: function () {
     var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').findProperty('isInstalled', false).hostName;
     var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').findProperty('isInstalled', false).hostName;
-    this.createComponent('NAMENODE', hostName, "HDFS");
+    this.createInstallComponentTask('NAMENODE', hostName, "HDFS");
   },
   },
 
 
   installJournalNodes: function () {
   installJournalNodes: function () {
     var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
     var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
-    this.createComponent('JOURNALNODE', hostNames, "HDFS");
+    this.createInstallComponentTask('JOURNALNODE', hostNames, "HDFS");
   },
   },
 
 
   startJournalNodes: function () {
   startJournalNodes: function () {
@@ -88,7 +88,7 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont
     var nnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
     var nnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
     var jnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
     var jnHostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName');
     var hostNames = nnHostNames.concat(jnHostNames).uniq();
     var hostNames = nnHostNames.concat(jnHostNames).uniq();
-    this.createComponent('HDFS_CLIENT', hostNames);
+    this.createInstallComponentTask('HDFS_CLIENT', hostNames, 'HDFS');
     App.router.get(this.get('content.controllerName')).saveHdfsClientHosts(hostNames);
     App.router.get(this.get('content.controllerName')).saveHdfsClientHosts(hostNames);
     App.clusterStatus.setClusterStatus({
     App.clusterStatus.setClusterStatus({
       clusterName: this.get('content.cluster.name'),
       clusterName: this.get('content.cluster.name'),
@@ -127,4 +127,3 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont
     this.updateConfigProperties(configItems);
     this.updateConfigProperties(configItems);
   }
   }
 });
 });
-

+ 2 - 3
ambari-web/app/controllers/main/admin/highAvailability/nameNode/step9_controller.js

@@ -60,7 +60,7 @@ App.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageCont
 
 
   installZKFC: function () {
   installZKFC: function () {
     var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
     var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName');
-    this.createComponent('ZKFC', hostName, "HDFS");
+    this.createInstallComponentTask('ZKFC', hostName, "HDFS");
   },
   },
 
 
   startZKFC: function () {
   startZKFC: function () {
@@ -85,7 +85,7 @@ App.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageCont
   },
   },
 
 
   installPXF: function () {
   installPXF: function () {
-    this.createComponent('PXF', this.get('secondNameNodeHost'), "PXF");
+    this.createInstallComponentTask('PXF', this.get('secondNameNodeHost'), "PXF");
   },
   },
 
 
   reconfigureHBase: function () {
   reconfigureHBase: function () {
@@ -162,4 +162,3 @@ App.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageCont
   }
   }
 
 
 });
 });
-

+ 1 - 2
ambari-web/app/controllers/main/admin/highAvailability/rangerAdmin/step4_controller.js

@@ -34,7 +34,7 @@ App.RAHighAvailabilityWizardStep4Controller = App.HighAvailabilityProgressPageCo
 
 
   installRangerAdmin: function () {
   installRangerAdmin: function () {
     var hostNames = this.get('content.raHosts.additionalRA');
     var hostNames = this.get('content.raHosts.additionalRA');
-    this.createComponent('RANGER_ADMIN', hostNames, "RANGER");
+    this.createInstallComponentTask('RANGER_ADMIN', hostNames, "RANGER");
   },
   },
 
 
   reconfigureRanger: function () {
   reconfigureRanger: function () {
@@ -85,4 +85,3 @@ App.RAHighAvailabilityWizardStep4Controller = App.HighAvailabilityProgressPageCo
     this.startServices(true);
     this.startServices(true);
   }
   }
 });
 });
-

+ 1 - 2
ambari-web/app/controllers/main/admin/highAvailability/resourceManager/step4_controller.js

@@ -44,7 +44,7 @@ App.RMHighAvailabilityWizardStep4Controller = App.HighAvailabilityProgressPageCo
 
 
   installResourceManager: function () {
   installResourceManager: function () {
     var hostName = this.get('content.rmHosts.additionalRM');
     var hostName = this.get('content.rmHosts.additionalRM');
-    this.createComponent('RESOURCEMANAGER', hostName, "YARN");
+    this.createInstallComponentTask('RESOURCEMANAGER', hostName, "YARN");
   },
   },
 
 
   reconfigureYARN: function () {
   reconfigureYARN: function () {
@@ -134,4 +134,3 @@ App.RMHighAvailabilityWizardStep4Controller = App.HighAvailabilityProgressPageCo
     this.startServices(true);
     this.startServices(true);
   }
   }
 });
 });
-

+ 15 - 1
ambari-web/app/mixins/wizard/wizardProgressPageController.js

@@ -725,6 +725,20 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create(App.InstallComponent, {
     } else {
     } else {
       this.onTaskError();
       this.onTaskError();
     }
     }
-  }
+  },
 
 
+  /**
+   * Same as <code>createComponent</code> but with kdc session check and status changes
+   * when KDC auth dialog dissmised.
+   *
+   * @see createComponent
+   */
+  createInstallComponentTask: function(componentName, hostName, serviceName, options) {
+    var self = this;
+    App.get('router.mainAdminKerberosController').getKDCSessionState(function() {
+      self.createComponent(componentName, hostName, serviceName);
+    }, function() {
+      self.onTaskError();
+    });
+  }
 });
 });

+ 43 - 4
ambari-web/test/mixins/wizard/wizardProgressPageController_test.js

@@ -21,7 +21,7 @@ var testHelpers = require('test/helpers');
 
 
 describe('App.wizardProgressPageControllerMixin', function() {
 describe('App.wizardProgressPageControllerMixin', function() {
   var mixedObject = Em.Object.extend(App.wizardProgressPageControllerMixin, {});
   var mixedObject = Em.Object.extend(App.wizardProgressPageControllerMixin, {});
-  
+
   describe('#createComponent', function() {
   describe('#createComponent', function() {
     var mixedObjectInstance;
     var mixedObjectInstance;
     beforeEach(function() {
     beforeEach(function() {
@@ -60,7 +60,7 @@ describe('App.wizardProgressPageControllerMixin', function() {
       });
       });
       App.serviceComponents = ['ZOOKEEPER_SERVER', 'ZOOKEEPER_CLIENT'];
       App.serviceComponents = ['ZOOKEEPER_SERVER', 'ZOOKEEPER_CLIENT'];
     });
     });
-    
+
     afterEach(function() {
     afterEach(function() {
       App.StackServiceComponent.find.restore();
       App.StackServiceComponent.find.restore();
       mixedObjectInstance.updateAndCreateServiceComponent.restore();
       mixedObjectInstance.updateAndCreateServiceComponent.restore();
@@ -68,7 +68,7 @@ describe('App.wizardProgressPageControllerMixin', function() {
       mixedObjectInstance.updateComponent.restore();
       mixedObjectInstance.updateComponent.restore();
       mixedObjectInstance.checkInstalledComponents.restore();
       mixedObjectInstance.checkInstalledComponents.restore();
     });
     });
-    
+
     it('should call `checkInstalledComponents` method', function() {
     it('should call `checkInstalledComponents` method', function() {
       mixedObjectInstance.createComponent('ZOOKEEPER_SERVER', 'host1', 'ZOOKEEPER');
       mixedObjectInstance.createComponent('ZOOKEEPER_SERVER', 'host1', 'ZOOKEEPER');
       expect(mixedObjectInstance.checkInstalledComponents.called).to.be.true;
       expect(mixedObjectInstance.checkInstalledComponents.called).to.be.true;
@@ -150,7 +150,7 @@ describe('App.wizardProgressPageControllerMixin', function() {
         ]
         ]
       }
       }
     ];
     ];
-    
+
     testsAjax.forEach(function(test) {
     testsAjax.forEach(function(test) {
       describe('called with params: ' + JSON.stringify(test.callParams), function() {
       describe('called with params: ' + JSON.stringify(test.callParams), function() {
         beforeEach(function() {
         beforeEach(function() {
@@ -168,5 +168,44 @@ describe('App.wizardProgressPageControllerMixin', function() {
     });
     });
   });
   });
 
 
+  describe('#createInstallComponentTask', function() {
+    var mixedObjectInstance;
+    beforeEach(function() {
+      mixedObjectInstance = mixedObject.create({});
+      sinon.stub(mixedObjectInstance, 'createComponent', Em.K);
+      sinon.stub(mixedObjectInstance, 'onTaskError', Em.K);
+      this.KDCStub = sinon.stub(App, 'get').withArgs('router.mainAdminKerberosController');
+    });
 
 
+    afterEach(function() {
+      mixedObjectInstance.createComponent.restore();
+      mixedObjectInstance.onTaskError.restore();
+      mixedObjectInstance.destroy();
+      mixedObjectInstance = null;
+      App.get.restore();
+      this.KDCStub = null;
+    });
+
+    it('when credentials are ok, createComponent method called', function() {
+      this.KDCStub.returns({
+        getKDCSessionState: function(sCallback, eCallback) {
+          sCallback();
+        }
+      });
+      mixedObjectInstance.createInstallComponentTask('componentName', 'hostName', 'serviceName');
+      assert.isTrue(mixedObjectInstance.createComponent.calledOnce, 'createComponent should be called');
+      assert.equal(JSON.stringify(mixedObjectInstance.createComponent.args[0]), JSON.stringify(['componentName', 'hostName', 'serviceName']), 'passed argument order should be the same');
+    });
+
+    it('when credentials are expired and KDC dialog cancelled task status should be changed to failed', function() {
+      this.KDCStub.returns({
+        getKDCSessionState: function(sCallback, eCallback) {
+          eCallback();
+        }
+      });
+      mixedObjectInstance.createInstallComponentTask('componentName', 'hostName', 'serviceName');
+      assert.isFalse(mixedObjectInstance.createComponent.calledOnce, 'createComponent should not be called');
+      assert.isTrue(mixedObjectInstance.onTaskError.called, 'onTaskError handler called');
+    });
+  });
 });
 });