YARN-4911. Bad placement policy in FairScheduler causes the RM to crash
This commit is contained in:
parent
d7d87deece
commit
a064865abf
|
@ -774,6 +774,12 @@ public class FairScheduler extends
|
|||
appRejectMsg = queueName + " is not a leaf queue";
|
||||
}
|
||||
}
|
||||
} catch (IllegalStateException se) {
|
||||
appRejectMsg = "Unable to match app " + rmApp.getApplicationId() +
|
||||
" to a queue placement policy, and no valid terminal queue " +
|
||||
" placement rule is configured. Please contact an administrator " +
|
||||
" to confirm that the fair scheduler configuration contains a " +
|
||||
" valid terminal queue placement rule.";
|
||||
} catch (InvalidQueueNameException qne) {
|
||||
appRejectMsg = qne.getMessage();
|
||||
} catch (IOException ioe) {
|
||||
|
|
|
@ -1604,6 +1604,34 @@ public class TestFairScheduler extends FairSchedulerTestBase {
|
|||
assertEquals("root.notdefault", rmApp2.getQueue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssignToBadDefaultQueue() throws Exception {
|
||||
conf.set(FairSchedulerConfiguration.ALLOCATION_FILE, ALLOC_FILE);
|
||||
|
||||
PrintWriter out = new PrintWriter(new FileWriter(ALLOC_FILE));
|
||||
out.println("<?xml version=\"1.0\"?>");
|
||||
out.println("<allocations>");
|
||||
out.println("<queuePlacementPolicy>");
|
||||
out.println("<rule name=\"specified\" create=\"false\" />");
|
||||
out.println("<rule name=\"default\" create=\"false\" />");
|
||||
out.println("</queuePlacementPolicy>");
|
||||
out.println("</allocations>");
|
||||
out.close();
|
||||
scheduler.init(conf);
|
||||
scheduler.start();
|
||||
scheduler.reinitialize(conf, resourceManager.getRMContext());
|
||||
|
||||
RMApp rmApp1 = new MockRMApp(0, 0, RMAppState.NEW);
|
||||
|
||||
try {
|
||||
FSLeafQueue queue1 = scheduler.assignToQueue(rmApp1, "default",
|
||||
"asterix");
|
||||
} catch (IllegalStateException ise) {
|
||||
fail("Bad queue placement policy terminal rule should not throw " +
|
||||
"exception ");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssignToNonLeafQueueReturnsNull() throws Exception {
|
||||
conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true");
|
||||
|
|
|
@ -131,9 +131,14 @@ public class TestQueuePlacementPolicy {
|
|||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("<queuePlacementPolicy>");
|
||||
sb.append(" <rule name='secondaryGroupExistingQueue' create='true'/>");
|
||||
sb.append(" <rule name='default' create='false'/>");
|
||||
sb.append(" <rule name='default' queue='otherdefault' create='false'/>");
|
||||
sb.append("</queuePlacementPolicy>");
|
||||
parse(sb.toString());
|
||||
QueuePlacementPolicy policy = parse(sb.toString());
|
||||
try {
|
||||
policy.assignAppToQueue("root.otherdefault", "user1");
|
||||
fail("Expect exception from having default rule with create=\'false\'");
|
||||
} catch (IllegalStateException se) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue