Updated Branches: refs/heads/trunk ac8afa72e -> ca558726d
AMBARI-4497. Hive check execute fails in secure environment after upgrading stack from 1.x. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ca558726 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ca558726 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ca558726 Branch: refs/heads/trunk Commit: ca558726d02eb5cf3d77f2fe3d2cd5a11639badc Parents: ac8afa7 Author: Sumit Mohanty <[email protected]> Authored: Wed Feb 5 18:09:31 2014 -0800 Committer: Sumit Mohanty <[email protected]> Committed: Wed Feb 5 18:09:31 2014 -0800 ---------------------------------------------------------------------- .../src/main/python/UpgradeHelper_HDP2.py | 39 +++++++++++++------- .../src/test/python/TestUpgradeScript_HDP2.py | 13 ++++--- 2 files changed, 33 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ca558726/ambari-server/src/main/python/UpgradeHelper_HDP2.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/UpgradeHelper_HDP2.py b/ambari-server/src/main/python/UpgradeHelper_HDP2.py index 4a04632..3253b98 100644 --- a/ambari-server/src/main/python/UpgradeHelper_HDP2.py +++ b/ambari-server/src/main/python/UpgradeHelper_HDP2.py @@ -49,6 +49,7 @@ HDFS_SITE_TAG = "hdfs-site" CORE_SITE_TAG = "core-site" YARN_SITE_TAG = "yarn-site" HBASE_SITE_TAG = "hbase-site" +HIVE_SITE_TAG = "hive-site" REPLACE_JH_HOST_NAME_TAG = "REPLACE_JH_HOST" REPLACE_RM_HOST_NAME_TAG = "REPLACE_RM_HOST" REPLACE_WITH_TAG = "REPLACE_WITH_" @@ -593,6 +594,12 @@ HBASE_SITE = { "zookeeper.session.timeout": "30000" } +HIVE_SITE = { + "hive.security.authorization.manager": "org.apache.hadoop.hive.ql.security.authorization.StorageBasedAuthorizationProvider", + "hive.security.metastore.authorization.manager": "org.apache.hadoop.hive.ql.security.authorization.StorageBasedAuthorizationProvider", + "hive.security.authenticator.manager": "org.apache.hadoop.hive.ql.security.ProxyUserAuthenticator" +} + class FatalException(Exception): def __init__(self, code, reason): @@ -869,7 +876,7 @@ def modify_configs(options, config_type): # Update global config if (config_type is None) or (config_type == GLOBAL_TAG): - update_config_using_existing(options, GLOBAL_TAG, GLOBAL.copy(), True) + update_config_using_existing(options, GLOBAL_TAG, GLOBAL.copy()) pass core_site_latest = rename_all_properties(get_config(options, CORE_SITE_TAG), PROPERTY_MAPPING) @@ -891,25 +898,31 @@ def modify_configs(options, config_type): pass pass pass - update_config_using_existing_properties(options, MAPRED_SITE_TAG, mapred_updated, mapred_site_latest, True) + update_config_using_existing_properties(options, MAPRED_SITE_TAG, mapred_updated, mapred_site_latest) pass # Update hdfs-site, core-site if (config_type is None) or (config_type == HDFS_SITE_TAG): - update_config_using_existing_properties(options, HDFS_SITE_TAG, HDFS_SITE.copy(), hdfs_site_latest, True) + update_config_using_existing_properties(options, HDFS_SITE_TAG, HDFS_SITE.copy(), hdfs_site_latest) pass if (config_type is None) or (config_type == CORE_SITE_TAG): - update_config_using_existing_properties(options, CORE_SITE_TAG, CORE_SITE.copy(), core_site_latest, True) + update_config_using_existing_properties(options, CORE_SITE_TAG, CORE_SITE.copy(), core_site_latest) pass # Update hbase-site if exists if (config_type is None) or (config_type == HBASE_SITE_TAG): tag, structured_resp = get_config_resp(options, HBASE_SITE_TAG, False) if structured_resp is not None: - update_config_using_existing(options, HBASE_SITE_TAG, HBASE_SITE.copy(), True) + update_config_using_existing(options, HBASE_SITE_TAG, HBASE_SITE.copy()) pass pass + # Update hive-site if exists + if (config_type is None) or (config_type == HIVE_SITE_TAG): + tag, structured_resp = get_config_resp(options, HIVE_SITE_TAG, False) + if structured_resp is not None: + update_config_using_existing(options, HIVE_SITE_TAG, HIVE_SITE.copy()) + pass pass @@ -922,14 +935,14 @@ def rename_all_properties(properties, name_mapping): return properties -def update_config_using_existing(options, type, properties_template, append_unprocessed=False): +def update_config_using_existing(options, type, properties_template): site_properties = get_config(options, type) - update_config_using_existing_properties(options, type, properties_template, site_properties, append_unprocessed) + update_config_using_existing_properties(options, type, properties_template, site_properties) pass def update_config_using_existing_properties(options, type, properties_template, - site_properties, append_unprocessed=False): + site_properties): keys_processed = [] keys_to_delete = [] for key in properties_template.keys(): @@ -952,14 +965,14 @@ def update_config_using_existing_properties(options, type, properties_template, pass pass pass - if append_unprocessed: - for key in site_properties.keys(): - if key not in keys_processed: - properties_template[key] = site_properties[key] - pass + + for key in site_properties.keys(): + if key not in keys_processed: + properties_template[key] = site_properties[key] pass pass pass + for key in keys_to_delete: del properties_template[key] pass http://git-wip-us.apache.org/repos/asf/ambari/blob/ca558726/ambari-server/src/test/python/TestUpgradeScript_HDP2.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestUpgradeScript_HDP2.py b/ambari-server/src/test/python/TestUpgradeScript_HDP2.py index 3289290..262ccb0 100644 --- a/ambari-server/src/test/python/TestUpgradeScript_HDP2.py +++ b/ambari-server/src/test/python/TestUpgradeScript_HDP2.py @@ -53,9 +53,9 @@ class TestUpgradeHDP2Script(TestCase): opm.parse_args.return_value = (options, args) get_config_mock.return_value = {"a1": "va1", "a2": "va2", "b1": "vb1", "b2": "vb2", "c1": "vc1", "d1": "d1"} site_template = {"y1": "vy1", "a1": "REPLACE_WITH_", "a2": "REPLACE_WITH_", "nb1": "REPLACE_WITH_b1", - "nb2": "REPLACE_WITH_b2", "d1": "DELETE_OLD", "b1" : "DELETE_OLD"} - expected_site = {"y1": "vy1", "a1": "va1", "a2": "va2", "nb1": "vb1", "nb2": "vb2", "c1": "vc1"} - UpgradeHelper_HDP2.update_config_using_existing(opm, "global", site_template, True) + "nb2": "REPLACE_WITH_b2", "d1": "DELETE_OLD", "b1" : "DELETE_OLD","c1": "vc2"} + expected_site = {"y1": "vy1", "a1": "va1", "a2": "va2", "nb1": "vb1", "nb2": "vb2", "c1": "vc2"} + UpgradeHelper_HDP2.update_config_using_existing(opm, "global", site_template) get_config_mock.assert_called_once_with(opm, "global") update_config_mock.assert_called_once_with(opm, expected_site, "global") pass @@ -63,7 +63,7 @@ class TestUpgradeHDP2Script(TestCase): @patch.object(UpgradeHelper_HDP2, 'update_config') @patch.object(UpgradeHelper_HDP2, 'get_config') @patch('optparse.Values') - def test_update_without_append(self, optparse_mock, get_config_mock, update_config_mock): + def test_update_with_appen_II(self, optparse_mock, get_config_mock, update_config_mock): opm = optparse_mock.return_value update_config_mock.return_value = None options = MagicMock() @@ -73,7 +73,7 @@ class TestUpgradeHDP2Script(TestCase): "X1": "X1"} site_template = {"y1": "vy1", "a1": "REPLACE_WITH_", "a2": "REPLACE_WITH_", "nb1": "REPLACE_WITH_b1", "nb2": "REPLACE_WITH_b2", "x1": "DELETE_OLD", "X1": "DELETE"} - expected_site = {"y1": "vy1", "a1": "va1", "a2": "va2", "nb1": "vb1", "nb2": "vb2", "X1": "DELETE"} + expected_site = {"y1": "vy1", "a1": "va1", "a2": "va2", "nb1": "vb1", "nb2": "vb2", "c1": "vc1","X1": "DELETE"} UpgradeHelper_HDP2.update_config_using_existing(opm, "global", site_template) get_config_mock.assert_called_once_with(opm, "global") update_config_mock.assert_called_once_with(opm, expected_site, "global") @@ -385,6 +385,7 @@ class TestUpgradeHDP2Script(TestCase): saved_hdfs = UpgradeHelper_HDP2.HDFS_SITE saved_core = UpgradeHelper_HDP2.CORE_SITE saved_habse = UpgradeHelper_HDP2.HBASE_SITE + saved_hive = UpgradeHelper_HDP2.HIVE_SITE saved_mapred = UpgradeHelper_HDP2.MAPRED_SITE try: UpgradeHelper_HDP2.GLOBAL = {"global2": "REPLACE_WITH_global1"} @@ -397,7 +398,7 @@ class TestUpgradeHDP2Script(TestCase): UpgradeHelper_HDP2.CORE_SITE = saved_core UpgradeHelper_HDP2.MAPRED_SITE = saved_mapred - self.assertEqual(7, len(curl_mock.call_args_list)) + self.assertEqual(8, len(curl_mock.call_args_list)) self.validate_update_config_call(curl_mock.call_args_list[0], "capacity-scheduler") self.validate_update_config_call(curl_mock.call_args_list[1], "yarn-site") self.validate_update_config_call(curl_mock.call_args_list[3], "mapred-site")
