Skip to content

Commit f1766e5

Browse files
YARN-10596. Allow static definition of childless ParentQueues with auto-queue-creation-v2 enabled. Contributed by Andras Gyori
1 parent a9ff726 commit f1766e5

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerQueueManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,21 @@ static CSQueue parseQueue(
238238
boolean isReservableQueue = conf.isReservable(fullQueueName);
239239
boolean isAutoCreateEnabled = conf.isAutoCreateChildQueueEnabled(
240240
fullQueueName);
241+
// if a queue is eligible for auto queue creation v2
242+
// it must be a ParentQueue (even if it is empty)
243+
boolean isAutoQueueCreationV2Enabled = conf.isAutoQueueCreationV2Enabled(
244+
fullQueueName);
241245
boolean isDynamicParent = false;
242246

247+
// Auto created parent queues might not have static children, but they
248+
// must be kept as a ParentQueue
243249
CSQueue oldQueue = oldQueues.get(fullQueueName);
244250
if (oldQueue instanceof ParentQueue) {
245251
isDynamicParent = ((ParentQueue) oldQueue).isDynamicQueue();
246252
}
247253

248-
if (childQueueNames.size() == 0 && !isDynamicParent) {
254+
if (childQueueNames.size() == 0 && !isDynamicParent &&
255+
!isAutoQueueCreationV2Enabled) {
249256
if (null == parent) {
250257
throw new IllegalStateException(
251258
"Queue configuration missing child queue names for " + queueName);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerNewQueueAutoCreation.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,46 @@ public void testAutoQueueCreationOnAppSubmission() throws Exception {
422422
Assert.assertTrue(user0.isDynamicQueue());
423423
}
424424

425+
@Test
426+
public void testChildlessParentQueueWhenAutoQueueCreationEnabled()
427+
throws Exception {
428+
startScheduler();
429+
csConf.setQueues("root", new String[]{"a", "b", "empty-auto-parent"});
430+
csConf.setNonLabeledQueueWeight("root", 1f);
431+
csConf.setNonLabeledQueueWeight("root.a", 1f);
432+
csConf.setNonLabeledQueueWeight("root.b", 1f);
433+
csConf.setQueues("root.a", new String[]{"a1"});
434+
csConf.setNonLabeledQueueWeight("root.a.a1", 1f);
435+
csConf.setAutoQueueCreationV2Enabled("root", true);
436+
csConf.setAutoQueueCreationV2Enabled("root.a", true);
437+
cs.reinitialize(csConf, mockRM.getRMContext());
438+
439+
CSQueue empty = cs.getQueue("root.empty-auto-parent");
440+
Assert.assertTrue("empty-auto-parent is not a LeafQueue",
441+
empty instanceof LeafQueue);
442+
empty.stopQueue();
443+
444+
csConf.setQueues("root", new String[]{"a", "b", "empty-auto-parent"});
445+
csConf.setNonLabeledQueueWeight("root", 1f);
446+
csConf.setNonLabeledQueueWeight("root.a", 1f);
447+
csConf.setNonLabeledQueueWeight("root.b", 1f);
448+
csConf.setQueues("root.a", new String[]{"a1"});
449+
csConf.setNonLabeledQueueWeight("root.a.a1", 1f);
450+
csConf.setAutoQueueCreationV2Enabled("root", true);
451+
csConf.setAutoQueueCreationV2Enabled("root.a", true);
452+
csConf.setAutoQueueCreationV2Enabled("root.empty-auto-parent", true);
453+
cs.reinitialize(csConf, mockRM.getRMContext());
454+
455+
empty = cs.getQueue("root.empty-auto-parent");
456+
Assert.assertTrue("empty-auto-parent is not a ParentQueue",
457+
empty instanceof ParentQueue);
458+
Assert.assertEquals("empty-auto-parent has children",
459+
0, empty.getChildQueues().size());
460+
Assert.assertTrue("empty-auto-parent is not eligible " +
461+
"for auto queue creation",
462+
((ParentQueue)empty).isEligibleForAutoQueueCreation());
463+
}
464+
425465
private LeafQueue createQueue(String queuePath) throws YarnException {
426466
return autoQueueHandler.autoCreateQueue(
427467
CSQueueUtils.extractQueuePath(queuePath));

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesCapacitySchedDynamicConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,6 @@ private static Configuration createWeightConfigInternal(boolean enableAqc) {
507507
if (enableAqc) {
508508
conf.put("yarn.scheduler.capacity.root.auto-queue-creation-v2.enabled",
509509
"true");
510-
conf.put("yarn.scheduler.capacity.root.default." +
511-
"auto-queue-creation-v2.enabled", "true");
512510
}
513511
return createConfiguration(conf);
514512
}

0 commit comments

Comments
 (0)