Sfoglia il codice sorgente

AMBARI-12736. Hbase user not being added to hbase.superuser in Hbase config.(vbrodetskyi)

Vitaly Brodetskyi 10 anni fa
parent
commit
0613c0a8a3

+ 6 - 0
ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-site.xml

@@ -327,6 +327,12 @@
     full privileges, regardless of stored ACLs, across the cluster.
     full privileges, regardless of stored ACLs, across the cluster.
     Only used when HBase security is enabled.
     Only used when HBase security is enabled.
     </description>
     </description>
+    <depends-on>
+      <property>
+        <type>hbase-env</type>
+        <name>hbase_user</name>
+      </property>
+    </depends-on>
   </property>
   </property>
 
 
   <property>
   <property>

+ 14 - 3
ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py

@@ -84,7 +84,7 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
       "YARN": self.recommendYARNConfigurations,
       "YARN": self.recommendYARNConfigurations,
       "MAPREDUCE2": self.recommendMapReduce2Configurations,
       "MAPREDUCE2": self.recommendMapReduce2Configurations,
       "HDFS": self.recommendHDFSConfigurations,
       "HDFS": self.recommendHDFSConfigurations,
-      "HBASE": self.recommendHbaseEnvConfigurations,
+      "HBASE": self.recommendHbaseConfigurations,
       "AMBARI_METRICS": self.recommendAmsConfigurations
       "AMBARI_METRICS": self.recommendAmsConfigurations
     }
     }
 
 
@@ -149,11 +149,20 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
     putHDFSProperty = self.putProperty(configurations, "hadoop-env", services)
     putHDFSProperty = self.putProperty(configurations, "hadoop-env", services)
     putHDFSProperty('namenode_opt_maxnewsize', max(int(clusterData['totalAvailableRam'] / 8), 256))
     putHDFSProperty('namenode_opt_maxnewsize', max(int(clusterData['totalAvailableRam'] / 8), 256))
 
 
-  def recommendHbaseEnvConfigurations(self, configurations, clusterData, services, hosts):
+  def recommendHbaseConfigurations(self, configurations, clusterData, services, hosts):
+    # recommendations for HBase env config
     putHbaseProperty = self.putProperty(configurations, "hbase-env", services)
     putHbaseProperty = self.putProperty(configurations, "hbase-env", services)
     putHbaseProperty('hbase_regionserver_heapsize', int(clusterData['hbaseRam']) * 1024)
     putHbaseProperty('hbase_regionserver_heapsize', int(clusterData['hbaseRam']) * 1024)
     putHbaseProperty('hbase_master_heapsize', int(clusterData['hbaseRam']) * 1024)
     putHbaseProperty('hbase_master_heapsize', int(clusterData['hbaseRam']) * 1024)
 
 
+    # recommendations for HBase site config
+    putHbaseSiteProperty = self.putProperty(configurations, "hbase-site", services)
+
+    if 'hbase-site' in services['configurations'] and 'hbase.superuser' in services['configurations']['hbase-site']['properties'] \
+      and 'hbase-env' in services['configurations'] and 'hbase_user' in services['configurations']['hbase-env']['properties'] \
+      and services['configurations']['hbase-env']['properties']['hbase_user'] != services['configurations']['hbase-site']['properties']['hbase.superuser']:
+      putHbaseSiteProperty("hbase.superuser", services['configurations']['hbase-env']['properties']['hbase_user'])
+
   def recommendAmsConfigurations(self, configurations, clusterData, services, hosts):
   def recommendAmsConfigurations(self, configurations, clusterData, services, hosts):
     putAmsEnvProperty = self.putProperty(configurations, "ams-env", services)
     putAmsEnvProperty = self.putProperty(configurations, "ams-env", services)
     putAmsHbaseSiteProperty = self.putProperty(configurations, "ams-hbase-site", services)
     putAmsHbaseSiteProperty = self.putProperty(configurations, "ams-hbase-site", services)
@@ -706,8 +715,10 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
     return self.toConfigurationValidationProblems(validationItems, "yarn-site")
     return self.toConfigurationValidationProblems(validationItems, "yarn-site")
 
 
   def validateHbaseEnvConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
   def validateHbaseEnvConfigurations(self, properties, recommendedDefaults, configurations, services, hosts):
+    hbase_site = getSiteProperties(configurations, "hbase-site")
     validationItems = [ {"config-name": 'hbase_regionserver_heapsize', "item": self.validatorLessThenDefaultValue(properties, recommendedDefaults, 'hbase_regionserver_heapsize')},
     validationItems = [ {"config-name": 'hbase_regionserver_heapsize', "item": self.validatorLessThenDefaultValue(properties, recommendedDefaults, 'hbase_regionserver_heapsize')},
-                        {"config-name": 'hbase_master_heapsize', "item": self.validatorLessThenDefaultValue(properties, recommendedDefaults, 'hbase_master_heapsize')} ]
+                        {"config-name": 'hbase_master_heapsize', "item": self.validatorLessThenDefaultValue(properties, recommendedDefaults, 'hbase_master_heapsize')},
+                        {"config-name": "hbase_user", "item": self.validatorEqualsPropertyItem(properties, "hbase_user", hbase_site, "hbase.superuser")} ]
     return self.toConfigurationValidationProblems(validationItems, "hbase-env")
     return self.toConfigurationValidationProblems(validationItems, "hbase-env")
 
 
   def validateHDFSConfigurationsEnv(self, properties, recommendedDefaults, configurations, services, hosts):
   def validateHDFSConfigurationsEnv(self, properties, recommendedDefaults, configurations, services, hosts):

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.2/services/stack_advisor.py

@@ -477,7 +477,7 @@ class HDP22StackAdvisor(HDP21StackAdvisor):
 
 
 
 
   def recommendHBASEConfigurations(self, configurations, clusterData, services, hosts):
   def recommendHBASEConfigurations(self, configurations, clusterData, services, hosts):
-    super(HDP22StackAdvisor, self).recommendHbaseEnvConfigurations(configurations, clusterData, services, hosts)
+    super(HDP22StackAdvisor, self).recommendHbaseConfigurations(configurations, clusterData, services, hosts)
     putHbaseEnvPropertyAttributes = self.putPropertyAttribute(configurations, "hbase-env")
     putHbaseEnvPropertyAttributes = self.putPropertyAttribute(configurations, "hbase-env")
 
 
     hmaster_host = self.getHostWithComponent("HBASE", "HBASE_MASTER", services, hosts)
     hmaster_host = self.getHostWithComponent("HBASE", "HBASE_MASTER", services, hosts)

+ 23 - 2
ambari-server/src/test/python/stacks/2.0.6/common/test_stack_advisor.py

@@ -615,7 +615,7 @@ class TestHDP206StackAdvisor(TestCase):
       actualItems.append(next)
       actualItems.append(next)
     self.checkEqual(expectedItems, actualItems)
     self.checkEqual(expectedItems, actualItems)
 
 
-  def test_recommendHbaseEnvConfigurations(self):
+  def test_recommendHbaseConfigurations(self):
     servicesList = ["HBASE"]
     servicesList = ["HBASE"]
     configurations = {}
     configurations = {}
     components = []
     components = []
@@ -637,7 +637,28 @@ class TestHDP206StackAdvisor(TestCase):
         }
         }
       ]
       ]
     }
     }
+    services = {
+      "services" : [
+      ],
+      "configurations": {
+        "hbase-site": {
+          "properties": {
+            "hbase.superuser": "hbase"
+          }
+        },
+        "hbase-env": {
+          "properties": {
+            "hbase_user": "hbase123"
+          }
+        }
+      }
+    }
     expected = {
     expected = {
+      'hbase-site': {
+        'properties': {
+          'hbase.superuser': 'hbase123'
+        }
+      },
       "hbase-env": {
       "hbase-env": {
         "properties": {
         "properties": {
           "hbase_master_heapsize": "8192",
           "hbase_master_heapsize": "8192",
@@ -649,7 +670,7 @@ class TestHDP206StackAdvisor(TestCase):
     clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None)
     clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None)
     self.assertEquals(clusterData['hbaseRam'], 8)
     self.assertEquals(clusterData['hbaseRam'], 8)
 
 
-    self.stackAdvisor.recommendHbaseEnvConfigurations(configurations, clusterData, None, None)
+    self.stackAdvisor.recommendHbaseConfigurations(configurations, clusterData, services, None)
     self.assertEquals(configurations, expected)
     self.assertEquals(configurations, expected)
 
 
   def test_recommendHDFSConfigurations(self):
   def test_recommendHDFSConfigurations(self):

+ 23 - 2
ambari-server/src/test/python/stacks/2.1/common/test_stack_advisor.py

@@ -161,7 +161,7 @@ class TestHDP21StackAdvisor(TestCase):
     self.stackAdvisor.recommendHiveConfigurations(configurations, clusterData, None, None)
     self.stackAdvisor.recommendHiveConfigurations(configurations, clusterData, None, None)
     self.assertEquals(configurations, expected)
     self.assertEquals(configurations, expected)
 
 
-  def test_recommendHbaseEnvConfigurations(self):
+  def test_recommendHbaseConfigurations(self):
     servicesList = ["HBASE"]
     servicesList = ["HBASE"]
     configurations = {}
     configurations = {}
     components = []
     components = []
@@ -183,7 +183,28 @@ class TestHDP21StackAdvisor(TestCase):
         }
         }
       ]
       ]
     }
     }
+    services = {
+      "services" : [
+      ],
+      "configurations": {
+        "hbase-site": {
+          "properties": {
+            "hbase.superuser": "hbase"
+          }
+        },
+        "hbase-env": {
+          "properties": {
+            "hbase_user": "hbase123"
+          }
+        }
+      }
+    }
     expected = {
     expected = {
+      'hbase-site': {
+        'properties': {
+          'hbase.superuser': 'hbase123'
+        }
+      },
       "hbase-env": {
       "hbase-env": {
         "properties": {
         "properties": {
           "hbase_master_heapsize": "8192",
           "hbase_master_heapsize": "8192",
@@ -195,7 +216,7 @@ class TestHDP21StackAdvisor(TestCase):
     clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None)
     clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None)
     self.assertEquals(clusterData['hbaseRam'], 8)
     self.assertEquals(clusterData['hbaseRam'], 8)
 
 
-    self.stackAdvisor.recommendHbaseEnvConfigurations(configurations, clusterData, None, None)
+    self.stackAdvisor.recommendHbaseConfigurations(configurations, clusterData, services, None)
     self.assertEquals(configurations, expected)
     self.assertEquals(configurations, expected)
 
 
   def test_recommendHDFSConfigurations(self):
   def test_recommendHDFSConfigurations(self):

+ 23 - 2
ambari-server/src/test/python/stacks/2.2/common/test_stack_advisor.py

@@ -1884,7 +1884,7 @@ class TestHDP22StackAdvisor(TestCase):
     self.stackAdvisor.recommendAmsConfigurations(configurations, clusterData, services, hosts)
     self.stackAdvisor.recommendAmsConfigurations(configurations, clusterData, services, hosts)
     self.assertEquals(configurations, expected)
     self.assertEquals(configurations, expected)
     
     
-  def test_recommendHbaseEnvConfigurations(self):
+  def test_recommendHbaseConfigurations(self):
     servicesList = ["HBASE"]
     servicesList = ["HBASE"]
     configurations = {}
     configurations = {}
     components = []
     components = []
@@ -1906,7 +1906,28 @@ class TestHDP22StackAdvisor(TestCase):
         }
         }
       ]
       ]
     }
     }
+    services = {
+      "services" : [
+      ],
+      "configurations": {
+        "hbase-site": {
+          "properties": {
+            "hbase.superuser": "hbase"
+          }
+        },
+        "hbase-env": {
+          "properties": {
+            "hbase_user": "hbase123"
+          }
+        }
+      }
+    }
     expected = {
     expected = {
+      'hbase-site': {
+        'properties': {
+          'hbase.superuser': 'hbase123'
+        }
+      },
       "hbase-env": {
       "hbase-env": {
         "properties": {
         "properties": {
           "hbase_master_heapsize": "8192",
           "hbase_master_heapsize": "8192",
@@ -1918,7 +1939,7 @@ class TestHDP22StackAdvisor(TestCase):
     clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None)
     clusterData = self.stackAdvisor.getConfigurationClusterSummary(servicesList, hosts, components, None)
     self.assertEquals(clusterData['hbaseRam'], 8)
     self.assertEquals(clusterData['hbaseRam'], 8)
 
 
-    self.stackAdvisor.recommendHbaseEnvConfigurations(configurations, clusterData, None, None)
+    self.stackAdvisor.recommendHbaseConfigurations(configurations, clusterData, services, None)
     self.assertEquals(configurations, expected)
     self.assertEquals(configurations, expected)
 
 
   def test_recommendHbaseSiteConfigurations(self):
   def test_recommendHbaseSiteConfigurations(self):