Ver código fonte

AMBARI-11613. With multiple KMS instances, hadoop.security.key.provider.path and dfs.encryption.key.provider.uri are set to an incorrect value. (akovalenko)

Aleksandr Kovalenko 10 anos atrás
pai
commit
1208fc5385

+ 2 - 5
ambari-web/app/controllers/main/host/details.js

@@ -916,11 +916,8 @@ App.MainHostDetailsController = Em.Controller.extend({
       }
     ];
 
-    for (var i = 0; i < rkmsHosts.length; i++) {
-      rkmsHosts[i] = rkmsHosts[i] + ':' + rkmsPort;
-    }
-    coreSiteConfigs.properties['hadoop.security.key.provider.path'] = 'kms://http@' + rkmsHosts.join(',') + '/kms';
-    hdfsSiteConfigs.properties['dfs.encryption.key.provider.uri'] = 'kms://http@' + rkmsHosts.join(',') + '/kms';
+    coreSiteConfigs.properties['hadoop.security.key.provider.path'] = 'kms://http@' + rkmsHosts.join(';') + ':' + rkmsPort + '/kms';
+    hdfsSiteConfigs.properties['dfs.encryption.key.provider.uri'] = 'kms://http@' + rkmsHosts.join(';') + ':' + rkmsPort + '/kms';
     this.saveConfigsBatch(groups, 'RANGER_KMS_SERVER', hostToInstall);
   },
 

+ 76 - 0
ambari-web/test/controllers/main/host/details_test.js

@@ -2564,4 +2564,80 @@ describe('App.MainHostDetailsController', function () {
     });
 
   });
+
+  describe('#onLoadRangerConfigs()', function () {
+
+    var cases = [
+      {
+        'kmsHosts': ['host1'],
+        'kmsPort': 'port',
+        'title': 'single host',
+        'hostToInstall': undefined,
+        'result': [
+          {
+            properties: {
+              'core-site': {'hadoop.security.key.provider.path': 'kms://http@host1:port/kms'},
+              'hdfs-site': {'dfs.encryption.key.provider.uri': 'kms://http@host1:port/kms'}
+            },
+            properties_attributes: {
+              'core-site': undefined,
+              'hdfs-site': undefined
+            }
+          }
+        ]
+      },
+      {
+        'kmsHosts': ['host1', 'host2'],
+        'kmsPort': 'port',
+        'title': 'two hosts',
+        'hostToInstall': 'host2',
+        'result': [
+          {
+            properties: {
+              'core-site': {'hadoop.security.key.provider.path': 'kms://http@host1;host2:port/kms'},
+              'hdfs-site': {'dfs.encryption.key.provider.uri': 'kms://http@host1;host2:port/kms'}
+            },
+            properties_attributes: {
+              'core-site': undefined,
+              'hdfs-site': undefined
+            }
+          }
+        ]
+      }
+    ];
+
+    beforeEach(function () {
+      sinon.spy(controller, 'saveConfigsBatch')
+    });
+
+    afterEach(function () {
+      controller.saveConfigsBatch.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        controller.set('rangerKMSServerHost', item.hostToInstall);
+        sinon.stub(controller, 'getRangerKMSServerHosts').returns(item.kmsHosts);
+        var data = {
+          items: [
+            {
+              type: 'kms-env',
+              properties: {'kms_port': item.kmsPort}
+            },
+            {
+              type: 'core-site',
+              properties: {}
+            },
+            {
+              type: 'hdfs-site',
+              properties: {}
+            }
+          ]
+        };
+        controller.onLoadRangerConfigs(data);
+        expect(controller.saveConfigsBatch.calledWith(item.result, 'RANGER_KMS_SERVER', item.hostToInstall)).to.be.true;
+      });
+    });
+
+  });
 });