YARN-8720. CapacityScheduler does not enforce max resource allocation check at queue level. Contributed by Tarun Parimi.

This commit is contained in:
Weiwei Yang 2018-09-14 16:33:51 +08:00
parent 568ebecdf4
commit f1a893fdbc
4 changed files with 11 additions and 3 deletions

View File

@ -231,7 +231,8 @@ public void allocate(ApplicationAttemptId appAttemptId,
}
}
Resource maximumCapacity = getScheduler().getMaximumResourceCapability();
Resource maximumCapacity =
getScheduler().getMaximumResourceCapability(app.getQueue());
// sanity check
try {

View File

@ -566,10 +566,11 @@ private List<ResourceRequest> validateAndCreateResourceRequest(
}
// Normalize all requests
String queue = submissionContext.getQueue();
for (ResourceRequest amReq : amReqs) {
SchedulerUtils.normalizeAndValidateRequest(amReq,
scheduler.getMaximumResourceCapability(),
submissionContext.getQueue(), scheduler, isRecovery, rmContext);
scheduler.getMaximumResourceCapability(queue),
queue, scheduler, isRecovery, rmContext);
amReq.setCapability(
scheduler.getNormalizedResource(amReq.getCapability()));

View File

@ -1209,6 +1209,9 @@ private static ResourceScheduler mockResourceScheduler() {
when(scheduler.getMaximumResourceCapability()).thenReturn(
Resources.createResource(
YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
when(scheduler.getMaximumResourceCapability(any(String.class))).thenReturn(
Resources.createResource(
YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
ResourceCalculator rs = mock(ResourceCalculator.class);
when(scheduler.getResourceCalculator()).thenReturn(rs);

View File

@ -1488,6 +1488,9 @@ private static YarnScheduler mockYarnScheduler() throws YarnException {
when(yarnScheduler.getMaximumResourceCapability()).thenReturn(
Resources.createResource(
YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
when(yarnScheduler.getMaximumResourceCapability(any(String.class)))
.thenReturn(Resources.createResource(
YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
when(yarnScheduler.getAppsInQueue(QUEUE_1)).thenReturn(
Arrays.asList(getApplicationAttemptId(101), getApplicationAttemptId(102)));
when(yarnScheduler.getAppsInQueue(QUEUE_2)).thenReturn(