YARN-4911. Bad placement policy in FairScheduler causes the RM to crash

This commit is contained in:
Karthik Kambatla 2016-10-20 20:57:04 -07:00
parent d7d87deece
commit a064865abf
3 changed files with 41 additions and 2 deletions

View File

@ -774,6 +774,12 @@ FSLeafQueue assignToQueue(RMApp rmApp, String queueName, String user) {
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) {

View File

@ -1604,6 +1604,34 @@ public void testAssignToQueue() throws Exception {
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");

View File

@ -131,9 +131,14 @@ public void testTerminals() throws Exception {
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