ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-12808 Ambari should not reset UIDs for existing users in a cluster (dsen)
Date Fri, 21 Aug 2015 14:41:20 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c30cca0b9 -> 485bd8af0


AMBARI-12808 Ambari should not reset UIDs for existing users in a cluster (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/485bd8af
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/485bd8af
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/485bd8af

Branch: refs/heads/trunk
Commit: 485bd8af0dbbe206b130f1736110bee6827b60f1
Parents: c30cca0
Author: Dmytro Sen <dsen@apache.org>
Authored: Fri Aug 21 17:41:12 2015 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Fri Aug 21 17:41:12 2015 +0300

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog212.java       | 30 +++++++++++
 .../0.96.0.2.0/configuration/hbase-env.xml      |  6 ---
 .../HDP/2.0.6/configuration/cluster-env.xml     |  8 +++
 .../2.0.6/hooks/before-ANY/scripts/params.py    |  2 +-
 .../before-ANY/scripts/shared_initialization.py |  9 ++--
 .../server/upgrade/UpgradeCatalog212Test.java   | 52 ++++++++++++++++++++
 .../python/stacks/2.0.6/configs/default.json    |  6 +--
 ambari-web/app/data/HDP2/site_properties.js     |  4 +-
 ambari-web/app/utils/config.js                  |  4 +-
 9 files changed, 104 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
index 6f20423..51ea8f7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
@@ -121,6 +121,36 @@ public class UpgradeCatalog212 extends AbstractUpgradeCatalog {
 
   protected void addMissingConfigs() throws AmbariException {
     updateHiveConfigs();
+    updateHbaseAndClusterConfigurations();
+  }
+
+  protected void updateHbaseAndClusterConfigurations() throws AmbariException {
+    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+    Clusters clusters = ambariManagementController.getClusters();
+
+    if (clusters != null) {
+      Map<String, Cluster> clusterMap = clusters.getClusters();
+
+      if ((clusterMap != null) && !clusterMap.isEmpty()) {
+        // Iterate through the clusters and perform any configuration updates
+        for (final Cluster cluster : clusterMap.values()) {
+          Config config = cluster.getDesiredConfigByType("hbase-env");
+
+          if (config != null) {
+            // Remove override_hbase_uid from hbase-env and add override_uid to cluster-env
+            String value = config.getProperties().get("override_hbase_uid");
+            if (value != null) {
+              Map<String, String> updates = new HashMap<String, String>();
+              Set<String> removes = new HashSet<String>();
+              updates.put("override_uid", value);
+              removes.add("override_hbase_uid");
+              updateConfigurationPropertiesForCluster(cluster, "hbase-env", new HashMap<String,
String>(), removes, false, true);
+              updateConfigurationPropertiesForCluster(cluster, "cluster-env", updates, true,
false);
+            }
+          }
+        }
+      }
+    }
   }
 
   protected void updateHiveConfigs() throws AmbariException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
index 403df33..03db5df 100644
--- a/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
+++ b/ambari-server/src/main/resources/common-services/HBASE/0.96.0.2.0/configuration/hbase-env.xml
@@ -152,11 +152,5 @@ export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -Xmn{{regionserver_xmn_
     </value>
   </property>
 
-  <property>
-    <name>override_hbase_uid</name>
-    <value>true</value>
-    <property-type>ADDITIONAL_USER_PROPERTY</property-type>
-    <description>Have Ambari manage UIDs</description>
-  </property>
 
 </configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
index 41140ab..47dffec 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
@@ -70,4 +70,12 @@ gpgcheck=0</value>
         <value>{{package_type}} {{base_url}} {{components}}</value>
         <description>Template of repositories for ubuntu.</description>
     </property>
+
+    <property>
+        <name>override_uid</name>
+        <value>true</value>
+        <property-type>ADDITIONAL_USER_PROPERTY</property-type>
+        <description>Have Ambari manage UIDs</description>
+    </property>
+
 </configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
index 2667e3b..8abd72b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/params.py
@@ -215,4 +215,4 @@ group_list = json.loads(config['hostLevelParams']['group_list'])
 host_sys_prepped = default("/hostLevelParams/host_sys_prepped", False)
 
 tez_am_view_acls = config['configurations']['tez-site']["tez.am.view-acls"]
-override_hbase_uid = config['configurations']['hbase-env']["override_hbase_uid"]
+override_uid = str(default("/configurations/cluster-env/override_uid", "true")).lower()

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
index 6c90aa4..9c4352a 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-ANY/scripts/shared_initialization.py
@@ -43,7 +43,10 @@ def setup_users():
           ignore_failures = params.ignore_groupsusers_create
       )
 
-    set_uid(params.smoke_user, params.smoke_user_dirs)
+    if params.override_uid == "true":
+      set_uid(params.smoke_user, params.smoke_user_dirs)
+    else:
+      print 'Skipping setting uid for smoke user as host is sys prepped'
   else:
     print 'Skipping creation of User and Group as host is sys prepped'
     pass
@@ -56,7 +59,7 @@ def setup_users():
                recursive = True,
                cd_access="a",
     )
-    if not params.host_sys_prepped and params.override_hbase_uid:
+    if not params.host_sys_prepped and params.override_uid == "true":
       set_uid(params.hbase_user, params.hbase_user_dirs)
     else:
       print 'Skipping setting uid for hbase user as host is sys prepped'
@@ -208,4 +211,4 @@ def setup_java():
             )
     Execute(("chown","-R", getpass.getuser(), params.java_home),
             sudo = True,
-            )
\ No newline at end of file
+            )

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
index fae8985..fa469e4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
@@ -155,6 +155,58 @@ public class UpgradeCatalog212Test {
   }
 
   @Test
+  public void testUpdateHBaseAdnClusterConfigs() throws Exception {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+    final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class);
+
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+
+    final Map<String, String> propertiesHbaseEnv = new HashMap<String, String>()
{
+      {
+        put("override_hbase_uid", "false");
+      }
+    };
+
+    final Config mockHbaseEnv = easyMockSupport.createNiceMock(Config.class);
+    expect(mockHbaseEnv.getProperties()).andReturn(propertiesHbaseEnv).once();
+
+    final Config mockClusterEnv = easyMockSupport.createNiceMock(Config.class);
+
+    final Map<String, String> propertiesExpectedHbaseEnv = new HashMap<String, String>();
+    final Map<String, String> propertiesExpectedClusterEnv = new HashMap<String,
String>() {{
+      put("override_uid", "false");
+    }};
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(ConfigHelper.class).toInstance(mockConfigHelper);
+        bind(Clusters.class).toInstance(mockClusters);
+
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+      put("normal", mockClusterExpected);
+    }}).once();
+
+    expect(mockClusterExpected.getDesiredConfigByType("cluster-env")).andReturn(mockClusterEnv).atLeastOnce();
+    expect(mockClusterExpected.getDesiredConfigByType("hbase-env")).andReturn(mockHbaseEnv).atLeastOnce();
+    expect(mockClusterEnv.getProperties()).andReturn(propertiesExpectedClusterEnv).atLeastOnce();
+    expect(mockHbaseEnv.getProperties()).andReturn(propertiesExpectedHbaseEnv).atLeastOnce();
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog212.class).updateHbaseAndClusterConfigurations();
+    easyMockSupport.verifyAll();
+
+  }
+
+  @Test
   public void testUpdateHiveConfigs() throws Exception {
     EasyMockSupport easyMockSupport = new EasyMockSupport();
     final AmbariManagementController  mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/configs/default.json b/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
index b45758c..a0da7f0 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
+++ b/ambari-server/src/test/python/stacks/2.0.6/configs/default.json
@@ -538,7 +538,8 @@
             "kerberos_domain": "EXAMPLE.COM",
             "user_group": "hadoop",
             "repo_suse_rhel_template": "[{{repo_id}}]\nname={{repo_id}}\n{% if mirror_list
%}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}\n\npath=/\nenabled=1\ngpgcheck=0",
-            "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}"
+            "repo_ubuntu_template": "{{package_type}} {{base_url}} {{components}}",
+          "override_uid" : "true"
       },
       "hbase-env": {
             "hbase_pid_dir": "/var/run/hbase", 
@@ -548,8 +549,7 @@
             "hbase_regionserver_heapsize": "1024m",
             "hbase_regionserver_xmn_max": "512",
             "hbase_regionserver_xmn_ratio": "0.2",
-            "hbase_log_dir": "/var/log/hbase",
-            "override_hbase_uid" : "true"
+            "hbase_log_dir": "/var/log/hbase"
         },
         "ganglia-env": {
             "gmond_user": "nobody", 

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index 11ea3b7..ed24dbc 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -4134,13 +4134,13 @@ var hdp2properties = [
   },
   {
     "id": "puppet var",
-    "name": "override_hbase_uid",
+    "name": "override_uid",
     "displayName": "Have Ambari manage UIDs",
     "displayType": "checkbox",
     "isReconfigurable": true,
     "isOverridable": false,
     "isVisible": true,
-    "filename": "hbase-env.xml",
+    "filename": "cluster-env.xml",
     "category": "Users and Groups"
   },
   {

http://git-wip-us.apache.org/repos/asf/ambari/blob/485bd8af/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index f1ab4b4..609b068 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -808,9 +808,9 @@ App.config = Em.Object.create({
       'zk_user': 'ZooKeeper User',
       'metadata_user': 'Atlas User',
       'ignore_groupsusers_create': 'Skip group modifications during install',
-      'override_hbase_uid': 'Have Ambari manage UIDs'
+      'override_uid': 'Have Ambari manage UIDs'
     };
-    var checkboxProperties = ['ignore_groupsusers_create', 'override_hbase_uid'];
+    var checkboxProperties = ['ignore_groupsusers_create', 'override_uid'];
     if (Em.isArray(config.property_type)) {
       if (config.property_type.contains('USER') || config.property_type.contains('ADDITIONAL_USER_PROPERTY')
|| config.property_type.contains('GROUP')) {
         propertyData.id = "puppet var";


Mime
View raw message