From 241d985467c4a318fa22a3f3007ee1827c94389c Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Wed, 18 Apr 2018 13:32:50 +0530 Subject: [PATCH] YARN-8145. yarn rmadmin -getGroups doesn't return updated groups for user. Contributed by Sunil G. --- .../resourcemanager/ResourceManager.java | 19 ------------------- .../resourcemanager/TestRMAdminService.java | 2 ++ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index f5d84a395b..a7d2fe8e5a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -34,7 +34,6 @@ import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem; import org.apache.hadoop.metrics2.source.JvmMetrics; import org.apache.hadoop.net.NetUtils; -import org.apache.hadoop.security.Groups; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authorize.ProxyUsers; @@ -254,9 +253,6 @@ protected void serviceInit(Configuration conf) throws Exception { // load core-site.xml loadConfigurationXml(YarnConfiguration.CORE_SITE_CONFIGURATION_FILE); - // Refresh user to group mappings during init. - refreshUserToGroupMappingsWithConf(); - // Do refreshSuperUserGroupsConfiguration with loaded core-site.xml // Or use RM specific configurations to overwrite the common ones first // if they exist @@ -340,21 +336,6 @@ protected void serviceInit(Configuration conf) throws Exception { super.serviceInit(this.conf); } - private void refreshUserToGroupMappingsWithConf() - throws YarnException, IOException { - Configuration newConf = new Configuration(false); - InputStream confFileInputStream = - configurationProvider - .getConfigurationInputStream(newConf, YarnConfiguration.CORE_SITE_CONFIGURATION_FILE); - if (confFileInputStream != null) { - newConf.addResource(confFileInputStream); - } - - // Do refreshUserToGroupsMappings with loaded core-site.xml - Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(newConf) - .refresh(); - } - private void loadConfigurationXml(String configurationFile) throws YarnException, IOException { InputStream configurationInputStream = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java index 03fc081333..f0484e122a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMAdminService.java @@ -722,6 +722,7 @@ public void testRefreshUserToGroupsMappingsWithLocalConfigurationProvider() { } // Make sure RM will use the updated GroupMappingServiceProvider + Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(conf).refresh(); List groupBefore = new ArrayList(Groups.getUserToGroupsMappingService( configuration).getGroups(user)); @@ -1099,6 +1100,7 @@ public void testRMInitialsWithFileSystemBasedConfigurationProvider() .get("hadoop.proxyuser.test.hosts").contains("test_hosts")); // verify UserToGroupsMappings + Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(conf).refresh(); List groupAfter = Groups.getUserToGroupsMappingService(configuration).getGroups( UserGroupInformation.getCurrentUser().getUserName());