YARN-10234. FS-CS converter: don't enable auto-create queue property for root. Contributed by Peter Bacsko

(cherry picked from commit 55fcbcb5c2)
This commit is contained in:
Szilard Nemeth 2020-04-15 07:24:04 +02:00
parent 7aad965198
commit f473473355
3 changed files with 22 additions and 7 deletions

View File

@ -27,6 +27,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.ConfigurableResource;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSLeafQueue;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FSQueue;
@ -225,7 +226,8 @@ private void emitPreemptionDisabled(String queueName, FSQueue queue) {
* @param queueName
*/
private void emitAutoCreateChildQueue(String queueName, FSQueue queue) {
if (autoCreateChildQueues && !queue.getChildQueues().isEmpty()) {
if (autoCreateChildQueues && !queue.getChildQueues().isEmpty()
&& !queueName.equals(CapacitySchedulerConfiguration.ROOT)) {
capacitySchedulerConfig.setBoolean(PREFIX + queueName +
".auto-create-child-queue.enabled", true);
}

View File

@ -649,6 +649,7 @@ public void testAutoCreateChildQueuesFalseWithoutPlacementRules()
testAutoCreateChildQueuesWithoutPlacementRules(false);
}
@SuppressWarnings("checkstyle:linelength")
private void testAutoCreateChildQueuesWithoutPlacementRules(
boolean allowUndeclaredPools) throws Exception {
config = new Configuration(false);
@ -661,15 +662,27 @@ private void testAutoCreateChildQueuesWithoutPlacementRules(
converter.convert(config);
Configuration convertedConf = converter.getCapacitySchedulerConfig();
String property =
String rootUserAutoCreate =
"yarn.scheduler.capacity.root.users.auto-create-child-queue.enabled";
String rootAutoCreate =
"yarn.scheduler.capacity.root.auto-create-child-queue.enabled";
String leafQueueAutoCreate =
"yarn.scheduler.capacity.root.users.joe.auto-create-child-queue.enabled";
if (allowUndeclaredPools) {
assertEquals("Auto-create queue wasn't enabled", true,
convertedConf.getBoolean(property, false));
assertEquals("Auto-create queue wasn't enabled for root.users", true,
convertedConf.getBoolean(rootUserAutoCreate, false));
assertNull("Auto-create queue shouldn't be set for root",
convertedConf.get(rootAutoCreate));
assertNull("Auto-create queue shouldn't be set for leaf",
convertedConf.get(leafQueueAutoCreate));
} else {
assertNull("Auto-create queue shouldn't be set",
convertedConf.get(property));
assertNull("Auto-create queue shouldn't be set for root.users",
convertedConf.get(rootUserAutoCreate));
assertNull("Auto-create queue shouldn't be set for root",
convertedConf.get(rootAutoCreate));
assertNull("Auto-create queue shouldn't be set for leaf",
convertedConf.get(leafQueueAutoCreate));
}
}

View File

@ -316,7 +316,7 @@ public void testQueueAutoCreateChildQueue() {
converter.convertQueueHierarchy(rootQueue);
Set<String> parentQueues = Sets.newHashSet("root",
Set<String> parentQueues = Sets.newHashSet(
"root.admins",
"root.users");