Sfoglia il codice sorgente

AMBARI-2689: Enable Security Wizard stops on step "2. Save Configurations" and doesn't let the user leave the wizard

Jaimin Jetly 12 anni fa
parent
commit
f60aebdab7

+ 53 - 25
ambari-web/app/controllers/main/admin/security/add/step4.js

@@ -265,11 +265,11 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
 
 
   checkServiceForConfigValue: function (value, serviceNames) {
-    serviceNames.forEach(function(_serviceName){
+    serviceNames.forEach(function (_serviceName) {
       if (!App.Service.find().mapProperty('serviceName').contains(_serviceName.name)) {
         value = value.replace(_serviceName.replace, '');
       }
-    },this);
+    }, this);
 
     return value;
   },
@@ -585,8 +585,9 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
       }
       _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
     }, this);
-    this.addSecureConfigs();
-    this.applyConfigurationsToCluster();
+    if (this.addSecureConfigs()) {
+      this.applyConfigurationsToCluster();
+    }
   },
 
   getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
@@ -600,30 +601,57 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
   },
 
   addSecureConfigs: function () {
-    this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
-      _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
-      if (_serviceConfigTags.siteName === 'global') {
-        var realmName = this.get('globalProperties').findProperty('name', 'kerberos_domain');
-        if (this.get('isNagiosSelected')) {
-          var nagiosPrincipalName = this.get('globalProperties').findProperty('name', 'nagios_principal_name');
-          nagiosPrincipalName.value = nagiosPrincipalName.value + '@' + realmName.value;
+    try {
+      this.get('serviceConfigTags').forEach(function (_serviceConfigTags) {
+        _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
+        if (_serviceConfigTags.siteName === 'global') {
+          var realmName = this.get('globalProperties').findProperty('name', 'kerberos_domain');
+          if (this.get('isNagiosSelected')) {
+            var nagiosPrincipalName = this.get('globalProperties').findProperty('name', 'nagios_principal_name');
+            nagiosPrincipalName.value = nagiosPrincipalName.value + '@' + realmName.value;
+          }
+          if (this.get('isZkSelected')) {
+            var zkPrincipalName = this.get('globalProperties').findProperty('name', 'zookeeper_principal_name');
+            zkPrincipalName.value = zkPrincipalName.value + '@' + realmName.value;
+          }
+          this.get('globalProperties').forEach(function (_globalProperty) {
+            if (!/_hosts?$/.test(_globalProperty.name)) {
+              _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
+            }
+          }, this);
         }
-        if (this.get('isZkSelected')) {
-          var zkPrincipalName = this.get('globalProperties').findProperty('name', 'zookeeper_principal_name');
-          zkPrincipalName.value = zkPrincipalName.value + '@' + realmName.value;
+        else {
+          this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
+            _serviceConfigTags.configs[_config.name] = _config.value;
+          }, this);
         }
-        this.get('globalProperties').forEach(function (_globalProperty) {
-          if (!/_hosts?$/.test(_globalProperty.name)) {
-            _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
-          }
-        }, this);
+      }, this);
+    } catch (err) {
+      var stage3 = this.get('stages').findProperty('stage', 'stage3');
+      if (stage3) {
+        stage3.set('isSuccess', false);
+        stage3.set('isError', true);
       }
-      else {
-        this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
-          _serviceConfigTags.configs[_config.name] = _config.value;
-        }, this);
+      if (err) {
+        console.log("Error: Error occurred while applying secure configs to the server. Error message: " + err);
       }
-    }, this);
+      this.onJsError();
+      return false;
+    }
+    return true;
+  },
+
+  onJsError: function () {
+    App.ModalPopup.show({
+      header: Em.I18n.t('common.error'),
+      secondary: false,
+      onPrimary: function () {
+        this.hide();
+      },
+      bodyClass: Ember.View.extend({
+        template: Ember.Handlebars.compile('<p>{{t admin.security.apply.configuration.error}}</p>')
+      })
+    });
   },
 
   saveStagesOnRequestId: function () {
@@ -657,7 +685,7 @@ App.MainAdminSecurityAddStep4Controller = Em.Controller.extend({
       if (!App.testMode) {
         App.clusterStatus.setClusterStatus({
           clusterName: this.get('clusterName'),
-          clusterState: 'ADD_SECURITY_STEP_3',
+          clusterState: 'ADD_SECURITY_STEP_4',
           wizardControllerName: App.router.get('addSecurityController.name'),
           localdb: App.db.data.AddSecurity
         });

+ 59 - 45
ambari-web/app/controllers/main/admin/security/disable.js

@@ -273,8 +273,9 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
       }
       _tag.configs = data.items.findProperty('type', _tag.siteName).properties;
     }, this);
-    this.removeSecureConfigs();
-    this.applyConfigurationsToCluster();
+    if (this.removeSecureConfigs()) {
+      this.applyConfigurationsToCluster();
+    }
   },
 
   getAllConfigurationsErrorCallback: function (request, ajaxOptions, error) {
@@ -344,51 +345,64 @@ App.MainAdminSecurityDisableController = Em.Controller.extend({
 
 
   removeSecureConfigs: function () {
-    this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
-      _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
-      if (_serviceConfigTags.siteName === 'global') {
-        this.get('secureProperties').forEach(function (_config) {
-          if (_config.name in _serviceConfigTags.configs) {
-            delete _serviceConfigTags.configs[_config.name];
-          }
-        }, this);
-        _serviceConfigTags.configs.security_enabled = 'false';
-        _serviceConfigTags.configs.dfs_datanode_address = '50010';
-        _serviceConfigTags.configs.dfs_datanode_http_address = '50075';
-      } else {
-        this.get('secureMapping').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
-          var configName = _config.name;
-          if (configName in _serviceConfigTags.configs) {
-            switch (configName) {
-              case 'dfs.datanode.address':
-                _serviceConfigTags.configs[configName] = '0.0.0.0:50010';
-                break;
-              case 'dfs.datanode.http.address':
-                _serviceConfigTags.configs[configName] = '0.0.0.0:50075';
-                break;
-              case 'mapred.task.tracker.task-controller':
-                _serviceConfigTags.configs[configName] = 'org.apache.hadoop.mapred.DefaultTaskController';
-                break;
-              case 'hbase.security.authentication':
-                _serviceConfigTags.configs[configName] = 'simple';
-                break;
-              case 'hbase.rpc.engine':
-                _serviceConfigTags.configs[configName] = 'org.apache.hadoop.hbase.ipc.WritableRpcEngine';
-                break;
-              case 'hbase.security.authorization':
-                _serviceConfigTags.configs[configName] = 'false';
-                break;
-              case 'zookeeper.znode.parent':
-                _serviceConfigTags.configs[configName] = '/hbase-unsecure';
-                break;
-              default:
-                delete _serviceConfigTags.configs[configName];
+    try {
+      this.get('serviceConfigTags').forEach(function (_serviceConfigTags, index) {
+        _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
+        if (_serviceConfigTags.siteName === 'global') {
+          this.get('secureProperties').forEach(function (_config) {
+            if (_config.name in _serviceConfigTags.configs) {
+              delete _serviceConfigTags.configs[_config.name];
             }
-          }
-          console.log("Not Deleted" + _config.name);
-        }, this);
+          }, this);
+          _serviceConfigTags.configs.security_enabled = 'false';
+          _serviceConfigTags.configs.dfs_datanode_address = '50010';
+          _serviceConfigTags.configs.dfs_datanode_http_address = '50075';
+        } else {
+          this.get('secureMapping').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
+            var configName = _config.name;
+            if (configName in _serviceConfigTags.configs) {
+              switch (configName) {
+                case 'dfs.datanode.address':
+                  _serviceConfigTags.configs[configName] = '0.0.0.0:50010';
+                  break;
+                case 'dfs.datanode.http.address':
+                  _serviceConfigTags.configs[configName] = '0.0.0.0:50075';
+                  break;
+                case 'mapred.task.tracker.task-controller':
+                  _serviceConfigTags.configs[configName] = 'org.apache.hadoop.mapred.DefaultTaskController';
+                  break;
+                case 'hbase.security.authentication':
+                  _serviceConfigTags.configs[configName] = 'simple';
+                  break;
+                case 'hbase.rpc.engine':
+                  _serviceConfigTags.configs[configName] = 'org.apache.hadoop.hbase.ipc.WritableRpcEngine';
+                  break;
+                case 'hbase.security.authorization':
+                  _serviceConfigTags.configs[configName] = 'false';
+                  break;
+                case 'zookeeper.znode.parent':
+                  _serviceConfigTags.configs[configName] = '/hbase-unsecure';
+                  break;
+                default:
+                  delete _serviceConfigTags.configs[configName];
+              }
+            }
+            console.log("Not Deleted" + _config.name);
+          }, this);
+        }
+      }, this);
+    } catch (err) {
+      var stage3 = this.get('stages').findProperty('stage', 'stage3');
+      if (stage3) {
+        stage3.set('isSuccess', false);
+        stage3.set('isError', true);
       }
-    }, this);
+      if (err) {
+        console.log("Error: Error occurred while applying secure configs to the server. Error message: " + err);
+      }
+      return false;
+    }
+    return true;
   },
 
   saveStagesOnRequestId: function () {

+ 4 - 2
ambari-web/app/messages.js

@@ -142,7 +142,8 @@ Em.I18n.translations = {
   'common.process': 'Process',
   'common.property': 'Property',
   'common.installed': 'Installed',
-
+  'common.persist.error' : 'Error in persisting web client state at ambari server',
+  'common.update.error' : 'Error in retrieving web client state from ambari server',
   'requestInfo.installComponents':'Install Components',
   'requestInfo.installServices':'Install Services',
   'requestInfo.startServices':'Start Services',
@@ -652,13 +653,14 @@ Em.I18n.translations = {
   'admin.security.step2.body.header': 'Configure Kerberos security properties',
   'admin.security.step3.notice': 'You need to create the following principals and keytabs on the hosts shown.<br />'+
   'You can download the list as a CSV file and use it to create a script to generate the principals and keytabs. ' +
-  'Once the principals and keytabs have been created, click on <i>Proceed</i> to continue. If you need to make configuration changes, click <i>Back</i>.',
+  'Once the principals and keytabs have been created, click on <i>Apply</i> to continue. If you need to make configuration changes, click <i>Back</i>.',
   'admin.security.step3.table.principal': 'Principal',
   'admin.security.step3.table.keytab': 'Keytab',
   'admin.security.step3.downloadCSV': 'Download CSV',
   'admin.security.step4.body.header': 'Applying kerberos security to the cluster',
   'admin.security.step4.body.success.header' : 'Kerberos-based security has been enabled on your cluster. Please wait while services are started in secure mode.',
   'admin.security.step4.body.failure.header' : 'Failed to enable Kerberos-based security on your cluster. Your cluster will keep running in non-secure mode.',
+  'admin.security.apply.configuration.error' : 'Failed to apply secure configurations to the cluster. Please navigate to "Configure Services" step and make sure all services are configured with appropriate values.',
   'admin.security.disable.body.header' : 'Disabling kerberos security on the cluster',
   'admin.security.disable.body.success.header': 'Kerberos-based security has been disabled on your cluster. Please wait while services are started in non-secure mode.',
   'admin.security.disable.body.failure.header': 'Failed to disable Kerberos-based security on your cluster. Your cluster will keep running in secure mode.',

+ 35 - 1
ambari-web/app/models/cluster_states.js

@@ -65,7 +65,18 @@ App.clusterStatus = Ember.Object.create({
           if (xhr.status == 404) {
             // default status already set
             console.log('Persist API did NOT find the key CLUSTER_CURRENT_STATUS');
+            return;
           }
+          App.ModalPopup.show({
+            header: Em.I18n.t('common.error'),
+            secondary: false,
+            onPrimary: function () {
+              this.hide();
+            },
+            bodyClass: Ember.View.extend({
+              template: Ember.Handlebars.compile('<p>{{t common.update.error}}</p>')
+            })
+          });
         },
         statusCode: require('data/statusCodes')
       }
@@ -112,11 +123,34 @@ App.clusterStatus = Ember.Object.create({
         data: JSON.stringify(keyValuePair),
         beforeSend: function () {
           console.log('BeforeSend: persistKeyValues', keyValuePair);
-        }
+        },
+        error: function () {
+          console.log("ERROR");
+          if(newValue.errorCallBack) {
+            newValue.errorCallBack();
+          } else {
+            this.clusterStatusErrorCallBack();
+          }
+        },
+        statusCode: require('data/statusCodes')
       });
       return newValue;
     }
   },
+
+  clusterStatusErrorCallBack: function() {
+    App.ModalPopup.show({
+      header: Em.I18n.t('common.error'),
+      secondary: false,
+      onPrimary: function () {
+        this.hide();
+      },
+      bodyClass: Ember.View.extend({
+        template: Ember.Handlebars.compile('<p>{{t common.persist.error}}</p>')
+      })
+    });
+  },
+
   /**
    * general info about cluster
    */