-
Notifications
You must be signed in to change notification settings - Fork 9.2k
YARN-11190. CS Mapping rule bug: User matcher does not work correctly for usernames with dot #4471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,9 @@ | |
|
|
||
| package org.apache.hadoop.yarn.server.resourcemanager.placement.csmappingrule; | ||
|
|
||
| import org.apache.commons.logging.Log; | ||
| import org.apache.commons.logging.LogFactory; | ||
| import org.apache.commons.logging.impl.Log4JLogger; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.security.GroupMappingServiceProvider; | ||
| import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap; | ||
|
|
@@ -33,6 +36,8 @@ | |
| import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration; | ||
| import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerQueueManager; | ||
| import org.apache.hadoop.yarn.util.Records; | ||
| import org.apache.log4j.Level; | ||
| import org.junit.Before; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
|
|
@@ -65,6 +70,11 @@ public class TestCSMappingPlacementRule { | |
|
|
||
| @Rule | ||
| public TemporaryFolder folder = new TemporaryFolder(); | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| setLoggerToDebug(); | ||
|
||
| } | ||
|
|
||
| private Map<String, Set<String>> userGroups = | ||
| ImmutableMap.<String, Set<String>>builder() | ||
|
|
@@ -85,6 +95,7 @@ private void createQueueHierarchy(CapacitySchedulerQueueManager queueManager) { | |
| .withQueue("root.user.alice") | ||
| .withQueue("root.user.bob") | ||
| .withQueue("root.user.test_dot_user") | ||
| .withQueue("root.user.testuser") | ||
| .withQueue("root.groups.main_dot_grp") | ||
| .withQueue("root.groups.sec_dot_test_dot_grp") | ||
| .withQueue("root.secondaryTests.unique") | ||
|
|
@@ -857,6 +868,54 @@ public List<MappingRule> getMappingRules() { | |
| assertPlace(engine, app, user, "root.man.testGroup0"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOriginalUserNameWithDotCanBeUsedInMatchExpression() throws IOException { | ||
| List<MappingRule> rules = new ArrayList<>(); | ||
| rules.add( | ||
| new MappingRule( | ||
| MappingRuleMatchers.createUserMatcher("test.user"), | ||
| (MappingRuleActions.createUpdateDefaultAction("root.user.testuser")) | ||
| .setFallbackSkip())); | ||
| rules.add(new MappingRule( | ||
| MappingRuleMatchers.createUserMatcher("test.user"), | ||
| (MappingRuleActions.createPlaceToDefaultAction()) | ||
| .setFallbackReject())); | ||
|
|
||
| CSMappingPlacementRule engine = setupEngine(true, rules); | ||
| ApplicationSubmissionContext app = createApp("app"); | ||
| assertPlace( | ||
| "test.user should be placed to root.user", | ||
| engine, app, "test.user", "root.user.testuser"); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOriginalGroupNameWithDotCanBeUsedInMatchExpression() throws IOException { | ||
| List<MappingRule> rules = new ArrayList<>(); | ||
| rules.add( | ||
| new MappingRule( | ||
| MappingRuleMatchers.createUserGroupMatcher("sec.test.grp"), | ||
| (MappingRuleActions.createUpdateDefaultAction("root.user.testuser")) | ||
| .setFallbackSkip())); | ||
| rules.add(new MappingRule( | ||
| MappingRuleMatchers.createUserMatcher("test.user"), | ||
| (MappingRuleActions.createPlaceToDefaultAction()) | ||
| .setFallbackReject())); | ||
|
|
||
| CSMappingPlacementRule engine = setupEngine(true, rules); | ||
| ApplicationSubmissionContext app = createApp("app"); | ||
| assertPlace( | ||
| "test.user should be placed to root.user", | ||
| engine, app, "test.user", "root.user.testuser"); | ||
| } | ||
|
|
||
| private static void setLoggerToDebug() { | ||
| Log log = LogFactory.getLog("org.apache.hadoop.yarn.server.resourcemanager.placement"); | ||
| if (log instanceof Log4JLogger) { | ||
| org.apache.log4j.Logger logger = ((Log4JLogger) log).getLogger(); | ||
| logger.setLevel(Level.DEBUG); | ||
| } | ||
| } | ||
|
|
||
| private CSMappingPlacementRule initPlacementEngine(CapacityScheduler cs) throws IOException { | ||
| CSMappingPlacementRule engine = new CSMappingPlacementRule(); | ||
| engine.setFailOnConfigError(true); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.