YARN-10135. FS-CS converter tool: issue warning on dynamic auto-create mapping rules. Contributed by Peter Bacsko

This commit is contained in:
Szilard Nemeth 2020-02-24 21:54:07 +01:00
parent 34cf63c7d0
commit 72fa9c7f1b
3 changed files with 42 additions and 10 deletions

View File

@ -76,6 +76,9 @@ public class FSConfigToCSConfigRuleHandler {
public static final String FAIR_AS_DRF = public static final String FAIR_AS_DRF =
"fairAsDrf.action"; "fairAsDrf.action";
public static final String MAPPED_DYNAMIC_QUEUE =
"mappedDynamicQueue.action";
@VisibleForTesting @VisibleForTesting
enum RuleAction { enum RuleAction {
WARNING, WARNING,
@ -122,6 +125,7 @@ public class FSConfigToCSConfigRuleHandler {
setActionForProperty(RESERVATION_SYSTEM); setActionForProperty(RESERVATION_SYSTEM);
setActionForProperty(QUEUE_AUTO_CREATE); setActionForProperty(QUEUE_AUTO_CREATE);
setActionForProperty(FAIR_AS_DRF); setActionForProperty(FAIR_AS_DRF);
setActionForProperty(MAPPED_DYNAMIC_QUEUE);
} }
public void handleMaxCapacityPercentage(String queueName) { public void handleMaxCapacityPercentage(String queueName) {
@ -180,7 +184,8 @@ public class FSConfigToCSConfigRuleHandler {
handle(QUEUE_AUTO_CREATE, handle(QUEUE_AUTO_CREATE,
null, null,
format( format(
"Placement rules: queue auto-create is not supported (type: %s)", "Placement rules: queue auto-create is not supported (type: %s),"
+ " please configure auto-create-child-queue property manually",
placementRule)); placementRule));
} }
@ -192,6 +197,21 @@ public class FSConfigToCSConfigRuleHandler {
queueName)); queueName));
} }
public void handleDynamicMappedQueue(String mapping, boolean create) {
String msg = "Mapping rule %s is dynamic - this might cause inconsistent"
+ " behaviour compared to FS.";
if (create) {
msg += " Also, setting auto-create-child-queue=true is"
+ " necessary, because the create flag was set to true on the"
+ " original placement rule.";
}
handle(MAPPED_DYNAMIC_QUEUE,
null,
format(msg, mapping));
}
private void handle(String actionName, String fsSetting, String message) { private void handle(String actionName, String fsSetting, String message) {
RuleAction action = actions.get(actionName); RuleAction action = actions.get(actionName);

View File

@ -57,7 +57,7 @@ class QueuePlacementConverter {
// nested rule // nested rule
if (userRule.getParentRule() != null) { if (userRule.getParentRule() != null) {
handleNestedRule(mapping, userRule); handleNestedRule(mapping, userRule, ruleHandler);
} else { } else {
if (!userAsDefaultQueue) { if (!userAsDefaultQueue) {
if (mapping.length() > 0) { if (mapping.length() > 0) {
@ -102,20 +102,28 @@ class QueuePlacementConverter {
} }
private void handleNestedRule(StringBuilder mapping, private void handleNestedRule(StringBuilder mapping,
UserPlacementRule userRule) { UserPlacementRule userRule, FSConfigToCSConfigRuleHandler ruleHandler) {
PlacementRule pr = userRule.getParentRule(); PlacementRule pr = userRule.getParentRule();
if (mapping.length() > 0) { if (mapping.length() > 0) {
mapping.append(RULE_SEPARATOR); mapping.append(RULE_SEPARATOR);
} }
if (pr instanceof PrimaryGroupPlacementRule) { if (pr instanceof PrimaryGroupPlacementRule) {
mapping.append("u:" + USER + ":" + PRIMARY_GROUP + "." + USER); String mappingString = "u:" + USER + ":" + PRIMARY_GROUP + "." + USER;
ruleHandler.handleDynamicMappedQueue(mappingString,
((PrimaryGroupPlacementRule) pr).getCreateFlag());
mapping.append(mappingString);
} else if (pr instanceof SecondaryGroupExistingPlacementRule) { } else if (pr instanceof SecondaryGroupExistingPlacementRule) {
String mappingString = "u:" + USER + ":" + SECONDARY_GROUP + "." + USER;
ruleHandler.handleDynamicMappedQueue(mappingString,
((SecondaryGroupExistingPlacementRule) pr).getCreateFlag());
mapping.append("u:" + USER + ":" + SECONDARY_GROUP + "." + USER); mapping.append("u:" + USER + ":" + SECONDARY_GROUP + "." + USER);
} else if (pr instanceof DefaultPlacementRule) { } else if (pr instanceof DefaultPlacementRule) {
DefaultPlacementRule defaultRule = (DefaultPlacementRule) pr; DefaultPlacementRule defaultRule = (DefaultPlacementRule) pr;
mapping.append("u:" + USER + ":") String mappingString =
.append(defaultRule.defaultQueueName) "u:" + USER + ":" + defaultRule.defaultQueueName + "." + USER;
.append("." + USER); ruleHandler.handleDynamicMappedQueue(mappingString,
defaultRule.getCreateFlag());
mapping.append(mappingString);
} else { } else {
throw new UnsupportedOperationException("Unsupported nested rule: " throw new UnsupportedOperationException("Unsupported nested rule: "
+ pr.getClass().getCanonicalName()); + pr.getClass().getCanonicalName());

View File

@ -19,6 +19,7 @@ import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.C
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.QUEUE_MAPPING; import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.QUEUE_MAPPING;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyZeroInteractions;
@ -180,7 +181,8 @@ public class TestQueuePlacementConverter {
Map<String, String> properties = convert(false); Map<String, String> properties = convert(false);
verifyMapping(properties, "u:%user:%primary_group.%user"); verifyMapping(properties, "u:%user:%primary_group.%user");
verifyZeroInteractions(ruleHandler); verify(ruleHandler).handleDynamicMappedQueue(
eq("u:%user:%primary_group.%user"), eq(false));
} }
@Test @Test
@ -194,7 +196,8 @@ public class TestQueuePlacementConverter {
Map<String, String> properties = convert(false); Map<String, String> properties = convert(false);
verifyMapping(properties, "u:%user:%secondary_group.%user"); verifyMapping(properties, "u:%user:%secondary_group.%user");
verifyZeroInteractions(ruleHandler); verify(ruleHandler).handleDynamicMappedQueue(
eq("u:%user:%secondary_group.%user"), eq(false));
} }
@Test @Test
@ -209,7 +212,8 @@ public class TestQueuePlacementConverter {
Map<String, String> properties = convert(false); Map<String, String> properties = convert(false);
verifyMapping(properties, "u:%user:abc.%user"); verifyMapping(properties, "u:%user:abc.%user");
verifyZeroInteractions(ruleHandler); verify(ruleHandler).handleDynamicMappedQueue(
eq("u:%user:abc.%user"), eq(false));
} }
@Test @Test