Skip to content

Commit c82ea52

Browse files
YARN-11513: Applications submitted to ambiguous queue fail during recovery if "Specified" Placement Rule is used (#5748)
1 parent cebcb44 commit c82ea52

File tree

3 files changed

+93
-2
lines changed

3 files changed

+93
-2
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ private void copyPlacementQueueToSubmissionContext(
10561056
LOG.info("Placed application with ID " + context.getApplicationId() +
10571057
" in queue: " + placementContext.getQueue() +
10581058
", original submission queue was: " + context.getQueue());
1059-
context.setQueue(placementContext.getQueue());
1059+
context.setQueue(placementContext.getFullQueuePath());
10601060
}
10611061
}
10621062

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void setUp() throws IOException {
283283
setupDispatcher(rmContext, conf);
284284
}
285285

286-
private static PlacementManager createMockPlacementManager(
286+
public static PlacementManager createMockPlacementManager(
287287
String userRegex, String placementQueue, String placementParentQueue
288288
) throws YarnException {
289289
PlacementManager placementMgr = mock(PlacementManager.class);

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

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,97 @@ public void testUAMRecoveryOnRMWorkPreservingRestart() throws Exception {
16511651
assertUnmanagedAMQueueMetrics(qm2, 1, 0, 0, 1);
16521652
}
16531653

1654+
// Test behavior of an app if two same name leaf queue with different queuePath
1655+
// during work preserving rm restart with %specified mapping Placement Rule.
1656+
// Test case does following:
1657+
//1. Submit an apps to queue root.joe.test.
1658+
//2. While the applications is running, restart the rm and
1659+
// check whether the app submitted to the queue it was submitted initially.
1660+
//3. Verify that application running successfully.
1661+
@Test(timeout = 60000)
1662+
public void testQueueRecoveryOnRMWorkPreservingRestart() throws Exception {
1663+
if (getSchedulerType() != SchedulerType.CAPACITY) {
1664+
return;
1665+
}
1666+
CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(conf);
1667+
1668+
csConf.setQueues(
1669+
CapacitySchedulerConfiguration.ROOT, new String[] {"default", "joe", "john"});
1670+
csConf.setCapacity(
1671+
CapacitySchedulerConfiguration.ROOT + "." + "joe", 25);
1672+
csConf.setCapacity(
1673+
CapacitySchedulerConfiguration.ROOT + "." + "john", 25);
1674+
csConf.setCapacity(
1675+
CapacitySchedulerConfiguration.ROOT + "." + "default", 50);
1676+
1677+
final String q1 = CapacitySchedulerConfiguration.ROOT + "." + "joe";
1678+
final String q2 = CapacitySchedulerConfiguration.ROOT + "." + "john";
1679+
csConf.setQueues(q1, new String[] {"test"});
1680+
csConf.setQueues(q2, new String[] {"test"});
1681+
csConf.setCapacity(
1682+
CapacitySchedulerConfiguration.ROOT + "." + "joe.test", 100);
1683+
csConf.setCapacity(
1684+
CapacitySchedulerConfiguration.ROOT + "." + "john.test", 100);
1685+
1686+
csConf.set(CapacitySchedulerConfiguration.MAPPING_RULE_JSON,
1687+
"{\"rules\" : [{\"type\": \"user\", \"policy\" : \"specified\", " +
1688+
"\"fallbackResult\" : \"skip\", \"matches\" : \"*\"}]}");
1689+
1690+
// start RM
1691+
rm1 = new MockRM(csConf);
1692+
rm1.start();
1693+
MockMemoryRMStateStore memStore =
1694+
(MockMemoryRMStateStore) rm1.getRMStateStore();
1695+
MockNM nm1 =
1696+
new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService());
1697+
nm1.registerNode();
1698+
1699+
RMContext newMockRMContext = rm1.getRMContext();
1700+
newMockRMContext.setQueuePlacementManager(TestAppManager.createMockPlacementManager(
1701+
"user1|user2", "test", "root.joe"));
1702+
1703+
MockRMAppSubmissionData data =
1704+
MockRMAppSubmissionData.Builder.createWithMemory(1024, rm1)
1705+
.withAppName("app")
1706+
.withQueue("root.joe.test")
1707+
.withUser("user1")
1708+
.withAcls(null)
1709+
.build();
1710+
1711+
RMApp app = MockRMAppSubmitter.submit(rm1, data);
1712+
MockAM am = MockRM.launchAndRegisterAM(app, rm1, nm1);
1713+
rm1.waitForState(app.getApplicationId(), RMAppState.RUNNING);
1714+
1715+
MockRM rm2 = new MockRM(csConf, memStore) {
1716+
@Override
1717+
protected RMAppManager createRMAppManager() {
1718+
return new RMAppManager(this.rmContext, this.scheduler,
1719+
this.masterService, this.applicationACLsManager, conf) {
1720+
@Override
1721+
ApplicationPlacementContext placeApplication(
1722+
PlacementManager placementManager,
1723+
ApplicationSubmissionContext context, String user,
1724+
boolean isRecovery) throws YarnException {
1725+
return super.placeApplication(
1726+
newMockRMContext.getQueuePlacementManager(), context, user, isRecovery);
1727+
}
1728+
};
1729+
}
1730+
};
1731+
1732+
nm1.setResourceTrackerService(rm2.getResourceTrackerService());
1733+
rm2.start();
1734+
RMApp recoveredApp0 =
1735+
rm2.getRMContext().getRMApps().get(app.getApplicationId());
1736+
1737+
rm2.waitForState(recoveredApp0.getApplicationId(), RMAppState.ACCEPTED);
1738+
am.setAMRMProtocol(rm2.getApplicationMasterService(), rm2.getRMContext());
1739+
am.registerAppAttempt(true);
1740+
rm2.waitForState(recoveredApp0.getApplicationId(), RMAppState.RUNNING);
1741+
1742+
Assert.assertEquals("root.joe.test", recoveredApp0.getQueue());
1743+
}
1744+
16541745
private void assertUnmanagedAMQueueMetrics(QueueMetrics qm, int appsSubmitted,
16551746
int appsPending, int appsRunning, int appsCompleted) {
16561747
Assert.assertEquals(appsSubmitted, qm.getUnmanagedAppsSubmitted());

0 commit comments

Comments
 (0)