YARN-10615. Fix Auto Queue Creation hierarchy construction to use queue path instead of short queue name. Contributed by Andras Gyori

This commit is contained in:
Szilard Nemeth 2021-02-05 17:43:01 +01:00
parent c19326c051
commit 5aa9866ec2
2 changed files with 23 additions and 2 deletions

View File

@ -55,13 +55,15 @@ public class CapacitySchedulerAutoQueueHandler {
List<ApplicationPlacementContext> parentsToCreate = new ArrayList<>();
ApplicationPlacementContext queueCandidateContext = parentContext;
CSQueue existingQueueCandidate = getQueue(queueCandidateContext.getQueue());
CSQueue existingQueueCandidate = getQueue(
queueCandidateContext.getFullQueuePath());
while (existingQueueCandidate == null) {
parentsToCreate.add(queueCandidateContext);
queueCandidateContext = CSQueueUtils.extractQueuePath(
queueCandidateContext.getParentQueue());
existingQueueCandidate = getQueue(queueCandidateContext.getQueue());
existingQueueCandidate = getQueue(
queueCandidateContext.getFullQueuePath());
}
// Reverse the collection to to represent the hierarchy to be created

View File

@ -525,6 +525,25 @@ public class TestCapacitySchedulerNewQueueAutoCreation
user0LeafQueue.getMinimumAllocation()).getMemorySize(), 1e-6);
}
@Test
public void testAutoCreateQueueIfAmbiguousQueueNames() throws Exception {
startScheduler();
AbstractCSQueue b = (AbstractCSQueue) cs.getQueue("root.b");
Assert.assertFalse(b.isDynamicQueue());
createQueue("root.a.b.b");
AbstractCSQueue bAutoParent = (AbstractCSQueue) cs.getQueue("root.a.b");
Assert.assertTrue(bAutoParent.isDynamicQueue());
Assert.assertTrue(bAutoParent.hasChildQueues());
AbstractCSQueue bAutoLeafQueue =
(AbstractCSQueue) cs.getQueue("root.a.b.b");
Assert.assertTrue(bAutoLeafQueue.isDynamicQueue());
Assert.assertFalse(bAutoLeafQueue.hasChildQueues());
}
private LeafQueue createQueue(String queuePath) throws YarnException {
return autoQueueHandler.autoCreateQueue(
CSQueueUtils.extractQueuePath(queuePath));