Skip to content

Commit 72fa9c7

Browse files
YARN-10135. FS-CS converter tool: issue warning on dynamic auto-create mapping rules. Contributed by Peter Bacsko
1 parent 34cf63c commit 72fa9c7

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/FSConfigToCSConfigRuleHandler.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public class FSConfigToCSConfigRuleHandler {
7676
public static final String FAIR_AS_DRF =
7777
"fairAsDrf.action";
7878

79+
public static final String MAPPED_DYNAMIC_QUEUE =
80+
"mappedDynamicQueue.action";
81+
7982
@VisibleForTesting
8083
enum RuleAction {
8184
WARNING,
@@ -122,6 +125,7 @@ public void initPropertyActions() {
122125
setActionForProperty(RESERVATION_SYSTEM);
123126
setActionForProperty(QUEUE_AUTO_CREATE);
124127
setActionForProperty(FAIR_AS_DRF);
128+
setActionForProperty(MAPPED_DYNAMIC_QUEUE);
125129
}
126130

127131
public void handleMaxCapacityPercentage(String queueName) {
@@ -180,7 +184,8 @@ public void handleQueueAutoCreate(String placementRule) {
180184
handle(QUEUE_AUTO_CREATE,
181185
null,
182186
format(
183-
"Placement rules: queue auto-create is not supported (type: %s)",
187+
"Placement rules: queue auto-create is not supported (type: %s),"
188+
+ " please configure auto-create-child-queue property manually",
184189
placementRule));
185190
}
186191

@@ -192,6 +197,21 @@ public void handleFairAsDrf(String queueName) {
192197
queueName));
193198
}
194199

200+
public void handleDynamicMappedQueue(String mapping, boolean create) {
201+
String msg = "Mapping rule %s is dynamic - this might cause inconsistent"
202+
+ " behaviour compared to FS.";
203+
204+
if (create) {
205+
msg += " Also, setting auto-create-child-queue=true is"
206+
+ " necessary, because the create flag was set to true on the"
207+
+ " original placement rule.";
208+
}
209+
210+
handle(MAPPED_DYNAMIC_QUEUE,
211+
null,
212+
format(msg, mapping));
213+
}
214+
195215
private void handle(String actionName, String fsSetting, String message) {
196216
RuleAction action = actions.get(actionName);
197217

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/QueuePlacementConverter.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Map<String, String> convertPlacementPolicy(PlacementManager placementManager,
5757

5858
// nested rule
5959
if (userRule.getParentRule() != null) {
60-
handleNestedRule(mapping, userRule);
60+
handleNestedRule(mapping, userRule, ruleHandler);
6161
} else {
6262
if (!userAsDefaultQueue) {
6363
if (mapping.length() > 0) {
@@ -102,20 +102,28 @@ Map<String, String> convertPlacementPolicy(PlacementManager placementManager,
102102
}
103103

104104
private void handleNestedRule(StringBuilder mapping,
105-
UserPlacementRule userRule) {
105+
UserPlacementRule userRule, FSConfigToCSConfigRuleHandler ruleHandler) {
106106
PlacementRule pr = userRule.getParentRule();
107107
if (mapping.length() > 0) {
108108
mapping.append(RULE_SEPARATOR);
109109
}
110110
if (pr instanceof PrimaryGroupPlacementRule) {
111-
mapping.append("u:" + USER + ":" + PRIMARY_GROUP + "." + USER);
111+
String mappingString = "u:" + USER + ":" + PRIMARY_GROUP + "." + USER;
112+
ruleHandler.handleDynamicMappedQueue(mappingString,
113+
((PrimaryGroupPlacementRule) pr).getCreateFlag());
114+
mapping.append(mappingString);
112115
} else if (pr instanceof SecondaryGroupExistingPlacementRule) {
116+
String mappingString = "u:" + USER + ":" + SECONDARY_GROUP + "." + USER;
117+
ruleHandler.handleDynamicMappedQueue(mappingString,
118+
((SecondaryGroupExistingPlacementRule) pr).getCreateFlag());
113119
mapping.append("u:" + USER + ":" + SECONDARY_GROUP + "." + USER);
114120
} else if (pr instanceof DefaultPlacementRule) {
115121
DefaultPlacementRule defaultRule = (DefaultPlacementRule) pr;
116-
mapping.append("u:" + USER + ":")
117-
.append(defaultRule.defaultQueueName)
118-
.append("." + USER);
122+
String mappingString =
123+
"u:" + USER + ":" + defaultRule.defaultQueueName + "." + USER;
124+
ruleHandler.handleDynamicMappedQueue(mappingString,
125+
defaultRule.getCreateFlag());
126+
mapping.append(mappingString);
119127
} else {
120128
throw new UnsupportedOperationException("Unsupported nested rule: "
121129
+ pr.getClass().getCanonicalName());

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/TestQueuePlacementConverter.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration.QUEUE_MAPPING;
2020
import static org.junit.Assert.assertEquals;
2121
import static org.junit.Assert.assertNotNull;
22+
import static org.mockito.ArgumentMatchers.eq;
2223
import static org.mockito.Mockito.mock;
2324
import static org.mockito.Mockito.verify;
2425
import static org.mockito.Mockito.verifyZeroInteractions;
@@ -180,7 +181,8 @@ public void testConvertNestedPrimaryGroupRule() {
180181
Map<String, String> properties = convert(false);
181182

182183
verifyMapping(properties, "u:%user:%primary_group.%user");
183-
verifyZeroInteractions(ruleHandler);
184+
verify(ruleHandler).handleDynamicMappedQueue(
185+
eq("u:%user:%primary_group.%user"), eq(false));
184186
}
185187

186188
@Test
@@ -194,7 +196,8 @@ public void testConvertNestedSecondaryGroupRule() {
194196
Map<String, String> properties = convert(false);
195197

196198
verifyMapping(properties, "u:%user:%secondary_group.%user");
197-
verifyZeroInteractions(ruleHandler);
199+
verify(ruleHandler).handleDynamicMappedQueue(
200+
eq("u:%user:%secondary_group.%user"), eq(false));
198201
}
199202

200203
@Test
@@ -209,7 +212,8 @@ public void testConvertNestedDefaultRule() {
209212
Map<String, String> properties = convert(false);
210213

211214
verifyMapping(properties, "u:%user:abc.%user");
212-
verifyZeroInteractions(ruleHandler);
215+
verify(ruleHandler).handleDynamicMappedQueue(
216+
eq("u:%user:abc.%user"), eq(false));
213217
}
214218

215219
@Test

0 commit comments

Comments
 (0)