YARN-11461. fix NPE in determineMissingParents (auto queue creation / CS). (#5506)

Change-Id: Iaaaf43a545588eaff8a0a20f6f3c27258a45f390
This commit is contained in:
Tamas Domok 2023-03-24 09:38:53 +01:00 committed by GitHub
parent 5cf62d1498
commit 69748aae32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -576,6 +576,11 @@ public List<String> determineMissingParents(
firstExistingStaticParent = getQueue(parentCandidate.toString()); firstExistingStaticParent = getQueue(parentCandidate.toString());
} }
if (firstExistingParent == null || firstExistingStaticParent == null) {
throw new SchedulerDynamicEditException("Could not auto-create queue "
+ queue + " parent queue does not exist.");
}
int maximumDepthOfStaticParent = csContext.getConfiguration().getMaximumAutoCreatedQueueDepth( int maximumDepthOfStaticParent = csContext.getConfiguration().getMaximumAutoCreatedQueueDepth(
firstExistingStaticParent.getQueuePath()); firstExistingStaticParent.getQueuePath());
if (firstStaticParentDistance > maximumDepthOfStaticParent) { if (firstStaticParentDistance > maximumDepthOfStaticParent) {

View File

@ -1251,6 +1251,17 @@ public void testParentQueueDynamicChildRemoval() throws Exception {
Assert.assertNull("root.e.e1-auto should have been removed", eAuto); Assert.assertNull("root.e.e1-auto should have been removed", eAuto);
} }
@Test()
public void testAutoCreateInvalidParent() throws Exception {
startScheduler();
Assert.assertThrows(SchedulerDynamicEditException.class,
() -> createQueue("invalid.queue"));
Assert.assertThrows(SchedulerDynamicEditException.class,
() -> createQueue("invalid.queue.longer"));
Assert.assertThrows(SchedulerDynamicEditException.class,
() -> createQueue("invalidQueue"));
}
protected AbstractLeafQueue createQueue(String queuePath) throws YarnException, protected AbstractLeafQueue createQueue(String queuePath) throws YarnException,
IOException { IOException {
return autoQueueHandler.createQueue(new QueuePath(queuePath)); return autoQueueHandler.createQueue(new QueuePath(queuePath));