瀏覽代碼

AMBARI-12856. Ambari UI should not restrict core-site to be only part of HDFS service

Sumit Mohanty 9 年之前
父節點
當前提交
4ff26efb17

+ 3 - 2
ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java

@@ -2386,8 +2386,9 @@ public class ClusterImpl implements Cluster {
             serviceName = entry.getKey();
             break;
           } else if (!serviceName.equals(entry.getKey())) {
-            String error = "Updating configs for multiple services by a " +
-                "single API request isn't supported";
+            String error = String.format("Updating configs for multiple services by a " +
+                "single API request isn't supported. Conflicting services %s and %s for %s",
+                                         serviceName, entry.getKey(), config.getType());
             IllegalArgumentException exception = new IllegalArgumentException(error);
             LOG.error(error + ", config version not created for {}", serviceName);
             throw exception;

+ 9 - 8
ambari-server/src/main/resources/common-services/YARN/2.1.0.2.0/package/scripts/yarn.py

@@ -172,14 +172,15 @@ def yarn(name = None):
   # During RU, Core Masters and Slaves need hdfs-site.xml
   # TODO, instead of specifying individual configs, which is susceptible to breaking when new configs are added,
   # RU should rely on all available in /usr/hdp/<version>/hadoop/conf
-  XmlConfig("hdfs-site.xml",
-            conf_dir=params.hadoop_conf_dir,
-            configurations=params.config['configurations']['hdfs-site'],
-            configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
-            owner=params.hdfs_user,
-            group=params.user_group,
-            mode=0644
-  )
+  if 'hdfs-site' in params.config['configurations']:
+    XmlConfig("hdfs-site.xml",
+              conf_dir=params.hadoop_conf_dir,
+              configurations=params.config['configurations']['hdfs-site'],
+              configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
+              owner=params.hdfs_user,
+              group=params.user_group,
+              mode=0644
+    )
 
   XmlConfig("mapred-site.xml",
             conf_dir=params.hadoop_conf_dir,

+ 17 - 15
ambari-web/app/controllers/wizard/step4_controller.js

@@ -279,21 +279,23 @@ App.WizardStep4Controller = Em.ArrayController.extend({
   fileSystemServiceValidation: function() {
     if(this.isDFSStack()){
       var primaryDFS = this.findProperty('isPrimaryDFS',true);
-      var primaryDfsDisplayName = primaryDFS.get('displayNameOnSelectServicePage');
-      var primaryDfsServiceName = primaryDFS.get('serviceName');
-      if (this.multipleDFSs()) {
-        var dfsServices = this.filterProperty('isDFS',true).filterProperty('isSelected',true).mapProperty('serviceName');
-        var services = dfsServices.map(function (item){
-          return  {
-            serviceName: item,
-            selected: item === primaryDfsServiceName
-          };
-        });
-        this.addValidationError({
-          id: 'multipleDFS',
-          callback: this.needToAddServicePopup,
-          callbackParams: [services, 'multipleDFS', primaryDfsDisplayName]
-        });
+      if (primaryDFS) {
+        var primaryDfsDisplayName = primaryDFS.get('displayNameOnSelectServicePage');
+        var primaryDfsServiceName = primaryDFS.get('serviceName');
+        if (this.multipleDFSs()) {
+          var dfsServices = this.filterProperty('isDFS',true).filterProperty('isSelected',true).mapProperty('serviceName');
+          var services = dfsServices.map(function (item){
+            return  {
+              serviceName: item,
+              selected: item === primaryDfsServiceName
+            };
+          });
+          this.addValidationError({
+            id: 'multipleDFS',
+            callback: this.needToAddServicePopup,
+            callbackParams: [services, 'multipleDFS', primaryDfsDisplayName]
+          });
+        }
       }
     }
   },

+ 3 - 1
ambari-web/app/mixins/common/configs/configs_saver.js

@@ -491,7 +491,9 @@ App.ConfigsSaverMixin = Em.Mixin.create({
       case 'mapred-queue-acls.xml':
         return false;
       case 'core-site.xml':
-        return ['HDFS', 'GLUSTERFS', 'RANGER_KMS'].contains(this.get('content.serviceName'));
+        var serviceName = this.get('content.serviceName');
+        var serviceType = App.StackService.find().findProperty('serviceName',serviceName).get('serviceType');
+        return ['HDFS', 'GLUSTERFS', 'RANGER_KMS'].contains(this.get('content.serviceName')) || serviceType === 'HCFS';
       default :
         return true;
     }

+ 41 - 8
ambari-web/test/mixins/common/configs/configs_saver_test.js

@@ -23,27 +23,60 @@ describe('App.ConfigsSaverMixin', function() {
   var instanceObject = mixinObject.create({});
 
   describe('#allowSaveSite()', function() {
-
+    var stackServices = [
+      Em.Object.create({
+        serviceName: 'HDFS',
+        serviceType: 'NONHCFS'
+      }),
+      Em.Object.create({
+        serviceName: 'S1',
+        serviceType: 'HCFS'
+      }),
+      Em.Object.create({
+        serviceName: 'S2',
+        serviceType: 'NONHCFS'
+      }),
+      Em.Object.create({
+        serviceName: 'S3'
+      })
+    ];
     beforeEach(function() {
       instanceObject.set('content', {});
+      sinon.stub(App.StackService, 'find', function () {
+        return stackServices;
+      });
+    });
+
+    afterEach(function() {
+      App.StackService.find.restore();
     });
 
     it('returns true by default', function() {
       expect(instanceObject.allowSaveSite('some-site')).to.be.true
     });
 
-    it('returns false for mapred-queue-acls.xml', function() {
-      expect(instanceObject.allowSaveSite('mapred-queue-acls.xml')).to.be.false
+    it('returns true for core-site and proper service', function() {
+      instanceObject.set('content.serviceName', 'HDFS');
+      expect(instanceObject.allowSaveSite('core-site.xml')).to.be.true
     });
 
-    it('returns false for core-site but not proper service', function() {
-      instanceObject.set('content.serviceName', 'ANY');
+    it('returns true for core-site and serviceType HCFS', function() {
+      instanceObject.set('content.serviceName', 'S1');
+      expect(instanceObject.allowSaveSite('core-site.xml')).to.be.true
+    });
+
+    it('returns false for core-site and serviceType not HCFS', function() {
+      instanceObject.set('content.serviceName', 'S2');
       expect(instanceObject.allowSaveSite('core-site.xml')).to.be.false
     });
 
-    it('returns true for core-site and proper service', function() {
-      instanceObject.set('content.serviceName', 'HDFS');
-      expect(instanceObject.allowSaveSite('core-site.xml')).to.be.true
+    it('returns false for core-site but serviceType undefined', function() {
+      instanceObject.set('content.serviceName', 'S3');
+      expect(instanceObject.allowSaveSite('core-site.xml')).to.be.false
+    });
+
+    it('returns false for mapred-queue-acls.xml', function() {
+      expect(instanceObject.allowSaveSite('mapred-queue-acls.xml')).to.be.false
     });
   });