From d1f71aaf02de75c4ef1b41913f3e3f77d5ff3cbe Mon Sep 17 00:00:00 2001 From: Sunil G Date: Sun, 4 Jun 2017 14:04:12 +0530 Subject: [PATCH] YARN-5988. RM unable to start in secure setup. Contributed by Ajith S. --- .../server/resourcemanager/AdminService.java | 8 +++ .../resourcemanager/TestRMAdminService.java | 56 ++++++++++++++----- 2 files changed, 50 insertions(+), 14 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/AdminService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java index 306bd864009..64078dd7a2a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/AdminService.java @@ -524,6 +524,7 @@ public class AdminService extends CompositeService implements checkRMStatus(user.getShortUserName(), argName, "refresh Service ACLs."); refreshServiceAcls(); + refreshActiveServicesAcls(); RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService"); @@ -537,6 +538,13 @@ public class AdminService extends CompositeService implements YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE); refreshServiceAcls(conf, policyProvider); + } + + private void refreshActiveServicesAcls() throws IOException, YarnException { + PolicyProvider policyProvider = RMPolicyProvider.getInstance(); + Configuration conf = + getConfiguration(new Configuration(false), + YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE); rmContext.getClientRMService().refreshServiceAcls(conf, policyProvider); rmContext.getApplicationMasterService().refreshServiceAcls( conf, policyProvider); 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 6e422064e11..3d301825421 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 @@ -514,20 +514,7 @@ public class TestRMAdminService { YarnException { StateChangeRequestInfo requestInfo = new StateChangeRequestInfo( HAServiceProtocol.RequestSource.REQUEST_BY_USER); - configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS, - "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider"); - configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true); - configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false); - configuration.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2"); - int base = 100; - for (String confKey : YarnConfiguration - .getServiceAddressConfKeys(configuration)) { - configuration.set(HAUtil.addSuffix(confKey, "rm1"), "0.0.0.0:" - + (base + 20)); - configuration.set(HAUtil.addSuffix(confKey, "rm2"), "0.0.0.0:" - + (base + 40)); - base = base * 2; - } + updateConfigurationForRMHA(); Configuration conf1 = new Configuration(configuration); conf1.set(YarnConfiguration.RM_HA_ID, "rm1"); Configuration conf2 = new Configuration(configuration); @@ -883,4 +870,45 @@ public class TestRMAdminService { } } + @Test + public void testSecureRMBecomeActive() throws IOException, + YarnException { + StateChangeRequestInfo requestInfo = new StateChangeRequestInfo( + HAServiceProtocol.RequestSource.REQUEST_BY_USER); + updateConfigurationForRMHA(); + configuration.setBoolean( + CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); + configuration.set(YarnConfiguration.RM_HA_ID, "rm1"); + // upload default configurations + uploadDefaultConfiguration(); + + ResourceManager resourceManager = new ResourceManager(); + try { + resourceManager.init(configuration); + resourceManager.start(); + Assert.assertTrue(resourceManager.getRMContext().getHAServiceState() + == HAServiceState.STANDBY); + resourceManager.adminService.transitionToActive(requestInfo); + } finally { + resourceManager.close(); + } + } + + private void updateConfigurationForRMHA() { + configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS, + "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider"); + configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true); + configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false); + configuration.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2"); + + int base = 1500; + for (String confKey : YarnConfiguration + .getServiceAddressConfKeys(configuration)) { + configuration.set(HAUtil.addSuffix(confKey, "rm1"), + "0.0.0.0:" + (base + 20)); + configuration.set(HAUtil.addSuffix(confKey, "rm2"), + "0.0.0.1:" + (base + 40)); + base = base * 2; + } + } }