YARN-10053. Use Shared Group Mapping Service in Placement Rules.
Contributed by Wilfred Spiegelenburg.
This commit is contained in:
parent
21ada4d1b0
commit
eca7e14c2f
|
@ -50,7 +50,8 @@ public class PrimaryGroupPlacementRule extends FSPlacementRule {
|
|||
@Override
|
||||
public boolean initialize(ResourceScheduler scheduler) throws IOException {
|
||||
super.initialize(scheduler);
|
||||
groupProvider = new Groups(((FairScheduler)scheduler).getConfig());
|
||||
groupProvider = Groups.
|
||||
getUserToGroupsMappingService(((FairScheduler)scheduler).getConfig());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,8 @@ public class SecondaryGroupExistingPlacementRule extends FSPlacementRule {
|
|||
@Override
|
||||
public boolean initialize(ResourceScheduler scheduler) throws IOException {
|
||||
super.initialize(scheduler);
|
||||
groupProvider = new Groups(((FairScheduler)scheduler).getConfig());
|
||||
groupProvider = Groups.
|
||||
getUserToGroupsMappingService(((FairScheduler)scheduler).getConfig());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -366,9 +366,9 @@ public class UserGroupMappingPlacementRule extends PlacementRule {
|
|||
|
||||
// initialize groups if mappings are present
|
||||
if (newMappings.size() > 0) {
|
||||
Groups groups = new Groups(conf);
|
||||
this.mappings = newMappings;
|
||||
this.groups = groups;
|
||||
this.groups = Groups.getUserToGroupsMappingService(
|
||||
((CapacityScheduler)scheduler).getConf());
|
||||
this.overrideWithQueueMappings = overrideWithQueueMappings;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ import org.apache.hadoop.fs.CommonConfigurationKeys;
|
|||
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
||||
import org.apache.hadoop.net.NetworkTopology;
|
||||
import org.apache.hadoop.security.Credentials;
|
||||
import org.apache.hadoop.security.Groups;
|
||||
import org.apache.hadoop.security.ShellBasedUnixGroupsMapping;
|
||||
import org.apache.hadoop.security.TestGroupsCaching;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
|
@ -5329,6 +5330,8 @@ public class TestCapacityScheduler extends CapacitySchedulerTestBase {
|
|||
TestGroupsCaching.FakeunPrivilegedGroupMapping.class, ShellBasedUnixGroupsMapping.class);
|
||||
config.set(CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES,
|
||||
"a1" +"=" + "agroup" + "");
|
||||
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(config);
|
||||
|
||||
config.set(CapacitySchedulerConfiguration.QUEUE_MAPPING,
|
||||
"g:agroup:%user");
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.apache.hadoop.security.Groups;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -305,6 +306,7 @@ public class TestCapacitySchedulerAutoCreatedQueueBase {
|
|||
TestGroupsCaching.FakeunPrivilegedGroupMapping.class, ShellBasedUnixGroupsMapping.class);
|
||||
conf.set(CommonConfigurationKeys.HADOOP_USER_GROUP_STATIC_OVERRIDES,
|
||||
TEST_GROUPUSER +"=" + TEST_GROUP + ";invalid_user=invalid_group");
|
||||
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(conf);
|
||||
|
||||
UserGroupMappingPlacementRule.QueueMapping userQueueMapping =
|
||||
new UserGroupMappingPlacementRule.QueueMapping(
|
||||
|
|
|
@ -29,6 +29,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
||||
import org.apache.hadoop.security.GroupMappingServiceProvider;
|
||||
import org.apache.hadoop.security.Groups;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
|
||||
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
|
||||
|
@ -560,8 +561,10 @@ public class TestQueuePlacementPolicy {
|
|||
sb.append(" </rule>");
|
||||
sb.append("</queuePlacementPolicy>");
|
||||
|
||||
// change the group resolution
|
||||
CONF.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
|
||||
PeriodGroupsMapping.class, GroupMappingServiceProvider.class);
|
||||
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(CONF);
|
||||
// User queue would be created under primary group queue, and the period
|
||||
// in the group name should be converted into _dot_
|
||||
createPolicy(sb.toString());
|
||||
|
@ -569,8 +572,10 @@ public class TestQueuePlacementPolicy {
|
|||
context = placementManager.placeApplication(asc, "user1");
|
||||
assertEquals("root.user1_dot_group.user1", context.getQueue());
|
||||
|
||||
// undo the group resolution change
|
||||
CONF.setClass(CommonConfigurationKeys.HADOOP_SECURITY_GROUP_MAPPING,
|
||||
SimpleGroupsMapping.class, GroupMappingServiceProvider.class);
|
||||
Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(CONF);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue