Jelajahi Sumber

AMBARI-16988. Invalid recommended value for storm.local.dir (/usr/hdp/hadoop/storm) (alexantonenko)

Alex Antonenko 9 tahun lalu
induk
melakukan
ecef55d3dd

+ 18 - 1
ambari-web/app/controllers/wizard/step7_controller.js

@@ -736,8 +736,25 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
     var localDB = {
       hosts: this.get('wizardController.content.hosts'),
       masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
-      slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
+      slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts'),
+      selectedStack: {}
     };
+    var selectedRepoVersion,
+        repoVersion;
+    if (this.get('wizardController.name') === 'addServiceController') {
+      repoVersion = App.RepositoryVersion.find().filter(function(i) {
+        return i.get('stackVersionType') === App.get('currentStackName') &&
+          i.get('stackVersionNumber') === App.get('currentStackVersionNumber');
+      })[0];
+      if (repoVersion) {
+        selectedRepoVersion = Em.get(repoVersion, 'repositoryVersion').split('-')[0];
+      }
+    } else {
+      selectedRepoVersion = Em.getWithDefault(App.Stack.find().findProperty('isSelected', true) || {}, 'repositoryVersion', false);
+    }
+    if (selectedRepoVersion) {
+      localDB.selectedStack = selectedRepoVersion;
+    }
     var configsByService = {}, dependencies = this.get('configDependencies');
 
     configs.forEach(function (_config) {

+ 30 - 18
ambari-web/app/utils/configs/mount_points_based_initializer_mixin.js

@@ -61,7 +61,7 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
     if (!setOfHostNames.length) {
       return configProperty;
     }
-    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
+    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo, localDB);
 
     var mPoint = allMountPoints[0].mountpoint;
     if (mPoint === "/") {
@@ -107,7 +107,7 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
       return configProperty;
     }
 
-    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo);
+    var allMountPoints = this._getAllMountPoints(setOfHostNames, hostsInfo, localDB);
     var mPoint = '';
 
     allMountPoints.forEach(function (eachDrive) {
@@ -207,26 +207,36 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
    *   <li>Should not be docker-dir</li>
    *   <li>Should not be boot-dir</li>
    *   <li>Should not be dev-dir</li>
+   *   <li>Valid mount point started from /usr/hdp/ should be /usr/hdp/current
+   *       or /usr/hdp/<STACK_VERSION_NUMBER> e.g. /usr/hdp/2.5.0.0
+   *   </li>
    * </ul>
    *
    * @param {{mountpoint: string, available: number}} mPoint
-   * @returns {boolean} true - valid, false - invalid
+   * @returns {function} true - valid, false - invalid
    * @private
    */
-  _filterMountPoint: function (mPoint) {
-    var isAvailable = mPoint.available !== 0;
-    if (!isAvailable) {
-      return false;
-    }
+  _filterMountPoint: function (localDB) {
+    var stackVersionNumber = [Em.getWithDefault(localDB.selectedStack || {}, 'repository_version', null)].compact();
+    return function(mPoint) {
+      var isAvailable = mPoint.available !== 0;
+      if (!isAvailable) {
+        return false;
+      }
 
-    var notHome = !['/', '/home'].contains(mPoint.mountpoint);
-    var notDocker = !['/etc/resolv.conf', '/etc/hostname', '/etc/hosts'].contains(mPoint.mountpoint);
-    var notBoot = mPoint.mountpoint && !(mPoint.mountpoint.startsWith('/boot')
-                                        || mPoint.mountpoint.startsWith('/mnt')
-                                        || mPoint.mountpoint.startsWith('/tmp'));
-    var notDev = !(['devtmpfs', 'tmpfs', 'vboxsf', 'CDFS'].contains(mPoint.type));
+      var stackRoot = '/usr/hdp';
+      var notHome = !['/', '/home'].contains(mPoint.mountpoint);
+      var notDocker = !['/etc/resolv.conf', '/etc/hostname', '/etc/hosts'].contains(mPoint.mountpoint);
+      var notBoot = mPoint.mountpoint && !(mPoint.mountpoint.startsWith('/boot')
+                                           || mPoint.mountpoint.startsWith('/mnt')
+                                           || mPoint.mountpoint.startsWith('/tmp'));
+      var notDev = !(['devtmpfs', 'tmpfs', 'vboxsf', 'CDFS'].contains(mPoint.type));
+      var validStackRootMount = !(mPoint.mountpoint.startsWith(stackRoot) && !['current'].concat(stackVersionNumber).filter(function(i) {
+        return mPoint.mountpoint === stackRoot + '/' + i;
+      }).length);
 
-    return notHome && notDocker && notBoot && notDev;
+      return notHome && notDocker && notBoot && notDev && validStackRootMount;
+    };
   },
 
   /**
@@ -258,11 +268,13 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
    *
    * @param {string[]} setOfHostNames
    * @param {object} hostsInfo
+   * @param {topologyLocalDB} localDB
    * @returns {string[]}
    * @private
    */
-  _getAllMountPoints: function (setOfHostNames, hostsInfo) {
-    var allMountPoints = [];
+  _getAllMountPoints: function (setOfHostNames, hostsInfo, localDB) {
+    var allMountPoints = [],
+        mountPointFilter = this._filterMountPoint(localDB);
     for (var i = 0; i < setOfHostNames.length; i++) {
       var hostname = setOfHostNames[i];
       var mountPointsPerHost = hostsInfo[hostname].disk_info;
@@ -276,7 +288,7 @@ App.MountPointsBasedInitializerMixin = Em.Mixin.create({
         };
       }
 
-      mountPointsPerHost.filter(this._filterMountPoint).forEach(function (mPoint) {
+      mountPointsPerHost.filter(mountPointFilter).forEach(function (mPoint) {
         if( !allMountPoints.findProperty("mountpoint", mPoint.mountpoint)) {
           allMountPoints.push(mPoint);
         }

+ 151 - 1
ambari-web/test/utils/configs/config_initializer_test.js

@@ -1217,7 +1217,157 @@ describe('App.ConfigInitializer', function () {
         expect(App.ConfigInitializer[name]).to.be.a.function;
       });
     });
-
   });
 
+  describe('#_filterMountPoint', function() {
+    var cases = [
+      {
+        mPoint: {
+          mountpoint: '/'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/home'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/etc/resolv.conf'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/etc/hostname'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/etc/hosts'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/boot'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/mnt'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/tmp'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'devtmpfs'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'tmpfs'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'vboxsf'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/some-dir',
+          type: 'CDFS'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/1'
+        },
+        localDB: {},
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/current'
+        },
+        localDB: {},
+        e: true
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/2.5'
+        },
+        localDB: {
+          selectedStack: {
+            repository_version: '2.5'
+          }
+        },
+        e: true
+      },
+      {
+        mPoint: {
+          mountpoint: '/usr/hdp/2.5.0'
+        },
+        localDB: {
+          selectedStack: {
+            repository_version: '2.5'
+          }
+        },
+        e: false
+      },
+      {
+        mPoint: {
+          mountpoint: '/normal/directory'
+        },
+        localDB: {
+          selectedStack: {
+            repository_version: '2.5'
+          }
+        },
+        e: true
+      }
+    ].forEach(function(test) {
+      it('mount point "{0}" should be {1}'.format(test.mPoint.mountpoint, test.e ? 'valid' : 'invalid'), function() {
+        var fFn = App.ConfigInitializer._filterMountPoint(test.localDB);
+        expect(fFn(test.mPoint)).to.be.eql(test.e);
+      });
+    });
+  });
 });