From 54da6a0d78c7832d647831b73030a1f75db932a9 Mon Sep 17 00:00:00 2001 From: Wangda Tan Date: Mon, 26 Mar 2018 11:16:06 -0700 Subject: [PATCH] YARN-8062. yarn rmadmin -getGroups returns group from which the user has been removed. (Sunil G via wangda) Change-Id: I80ed63846502bf7751b890b6c6c6a7c0679e2b4a (cherry picked from commit 5d381570f83022b411a8740d58486a7f68ab2af6) --- .../resourcemanager/ResourceManager.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 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 5140c9fa558..38da7f5e5c3 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 @@ -260,9 +260,8 @@ public class ResourceManager extends CompositeService implements Recoverable { // load core-site.xml loadConfigurationXml(YarnConfiguration.CORE_SITE_CONFIGURATION_FILE); - // Do refreshUserToGroupsMappings with loaded core-site.xml - Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(this.conf) - .refresh(); + // 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 @@ -347,6 +346,21 @@ public class ResourceManager extends CompositeService implements Recoverable { 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 =