Skip to content

Commit cae3894

Browse files
committed
COMPX-6769: YARN-10869. CS considers only the default maximum-allocation-mb/vcore property as a maximum when it creates dynamic queues (apache#3225)
Co-authored-by: Benjamin Teke <bteke@cloudera.com> (cherry picked from commit ac0a4e7) Change-Id: Ia8bfcf0694dc707ba5a5dabf042f30540da14084
1 parent 500c90c commit cae3894

File tree

4 files changed

+76
-6
lines changed

4 files changed

+76
-6
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/AbstractCSQueue.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,14 @@ protected void setDynamicQueueProperties(
518518

519519
private void setupMaximumAllocation(CapacitySchedulerConfiguration csConf) {
520520
String myQueuePath = getQueuePath();
521+
/* YARN-10869: When using AutoCreatedLeafQueues, the passed configuration
522+
* object is a cloned one containing only the template configs
523+
* (see ManagedParentQueue#getLeafQueueConfigs). To ensure that the actual
524+
* cluster maximum allocation is fetched the original config object should
525+
* be used.
526+
*/
521527
Resource clusterMax = ResourceUtils
522-
.fetchMaximumAllocationFromConfig(csConf);
528+
.fetchMaximumAllocationFromConfig(this.csContext.getConfiguration());
523529
Resource queueMax = csConf.getQueueMaximumAllocation(myQueuePath);
524530

525531
maximumAllocation = Resources.clone(

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,6 +2449,15 @@ public void setAutoCreatedLeafQueueConfigDefaultNodeLabelExpression(String
24492449
setDefaultNodeLabelExpression(leafQueueConfPrefix, expression);
24502450
}
24512451

2452+
@Private
2453+
@VisibleForTesting
2454+
public void setAutoCreatedLeafQueueConfigMaximumAllocation(String
2455+
queuePath, String expression) {
2456+
String leafQueueConfPrefix = getAutoCreatedQueueTemplateConfPrefix(
2457+
queuePath);
2458+
setQueueMaximumAllocation(leafQueueConfPrefix, expression);
2459+
}
2460+
24522461
public static String getUnits(String resourceValue) {
24532462
String units;
24542463
for (int i = 0; i < resourceValue.length(); i++) {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoCreatedQueueBase.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ public static CapacitySchedulerConfiguration setupQueueConfiguration(
404404
conf.setAutoCreatedLeafQueueConfigMaxCapacity(C, 100.0f);
405405
conf.setAutoCreatedLeafQueueConfigUserLimit(C, 100);
406406
conf.setAutoCreatedLeafQueueConfigUserLimitFactor(C, 3.0f);
407+
conf.setAutoCreatedLeafQueueConfigUserLimitFactor(C, 3.0f);
408+
conf.setAutoCreatedLeafQueueConfigMaximumAllocation(C,
409+
"memory-mb=10240,vcores=6");
407410

408411
conf.setAutoCreatedLeafQueueTemplateCapacityByLabel(C, NODEL_LABEL_GPU,
409412
NODE_LABEL_GPU_TEMPLATE_CAPACITY);
@@ -552,9 +555,31 @@ protected CapacitySchedulerConfiguration setupSchedulerConfiguration() {
552555
schedConf.setInt(YarnConfiguration.RESOURCE_TYPES
553556
+ ".memory-mb.maximum-allocation", 16384);
554557

558+
555559
return new CapacitySchedulerConfiguration(schedConf);
556560
}
557561

562+
protected void setSchedulerMinMaxAllocation(CapacitySchedulerConfiguration conf) {
563+
unsetMinMaxAllocation(conf);
564+
565+
conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, 1);
566+
conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, 8);
567+
conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 1024);
568+
conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 18384);
569+
570+
}
571+
572+
private void unsetMinMaxAllocation(CapacitySchedulerConfiguration conf) {
573+
conf.unset(YarnConfiguration.RESOURCE_TYPES
574+
+ ".vcores.minimum-allocation");
575+
conf.unset(YarnConfiguration.RESOURCE_TYPES
576+
+ ".vcores.maximum-allocation");
577+
conf.unset(YarnConfiguration.RESOURCE_TYPES
578+
+ ".memory-mb.minimum-allocation");
579+
conf.unset(YarnConfiguration.RESOURCE_TYPES
580+
+ ".memory-mb.maximum-allocation");
581+
}
582+
558583
protected MockRM setupSchedulerInstance() throws Exception {
559584
CapacitySchedulerConfiguration conf = setupSchedulerConfiguration();
560585

@@ -646,10 +671,11 @@ protected void validateUserAndAppLimits(
646671
}
647672

648673
protected void validateContainerLimits(
649-
AutoCreatedLeafQueue autoCreatedLeafQueue) {
650-
assertEquals(8,
674+
AutoCreatedLeafQueue autoCreatedLeafQueue, int vCoreLimit,
675+
long memorySize) {
676+
assertEquals(vCoreLimit,
651677
autoCreatedLeafQueue.getMaximumAllocation().getVirtualCores());
652-
assertEquals(16384,
678+
assertEquals(memorySize,
653679
autoCreatedLeafQueue.getMaximumAllocation().getMemorySize());
654680
}
655681

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacitySchedulerAutoQueueCreation.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void testAutoCreateLeafQueueCreation() throws Exception {
144144
expectedChildQueueAbsCapacity, accessibleNodeLabelsOnC);
145145

146146
validateUserAndAppLimits(autoCreatedLeafQueue, 1000, 1000);
147-
validateContainerLimits(autoCreatedLeafQueue);
147+
validateContainerLimits(autoCreatedLeafQueue, 6, 10240);
148148

149149
assertTrue(autoCreatedLeafQueue
150150
.getOrderingPolicy() instanceof FairOrderingPolicy);
@@ -173,6 +173,35 @@ public void testAutoCreateLeafQueueCreation() throws Exception {
173173
}
174174
}
175175

176+
@Test(timeout = 20000)
177+
public void testAutoCreateLeafQueueCreationSchedulerMaximumAllocation()
178+
throws Exception {
179+
try {
180+
// Check the minimum/maximum allocation settings via the
181+
// yarn.scheduler.minimum/maximum-allocation-mb/vcore property
182+
setSchedulerMinMaxAllocation(cs.getConfiguration());
183+
cs.getConfiguration().setAutoCreatedLeafQueueConfigMaximumAllocation(C,
184+
"memory-mb=18384,vcores=8");
185+
cs.reinitialize(cs.getConfiguration(), mockRM.getRMContext());
186+
187+
// submit an app
188+
submitApp(mockRM, cs.getQueue(PARENT_QUEUE), USER0, USER0, 1, 1);
189+
190+
// check preconditions
191+
List<ApplicationAttemptId> appsInC = cs.getAppsInQueue(PARENT_QUEUE);
192+
assertEquals(1, appsInC.size());
193+
assertNotNull(cs.getQueue(USER0));
194+
195+
AutoCreatedLeafQueue autoCreatedLeafQueue =
196+
(AutoCreatedLeafQueue) cs.getQueue(USER0);
197+
198+
validateContainerLimits(autoCreatedLeafQueue, 8, 18384);
199+
} finally {
200+
cleanupQueue(USER0);
201+
cleanupQueue(TEST_GROUPUSER);
202+
}
203+
}
204+
176205
@Test(timeout = 20000)
177206
public void testAutoCreateLeafQueueCreationUsingFullParentPath()
178207
throws Exception {
@@ -917,7 +946,7 @@ public void testReinitializeQueuesWithAutoCreatedLeafQueues()
917946
validateCapacities(user3Queue, 0.3f, 0.09f, 0.4f,0.2f);
918947

919948
validateUserAndAppLimits(user3Queue, 900, 900);
920-
validateContainerLimits(user3Queue);
949+
validateContainerLimits(user3Queue, 6, 10240);
921950

922951
GuaranteedOrZeroCapacityOverTimePolicy autoCreatedQueueManagementPolicy =
923952
(GuaranteedOrZeroCapacityOverTimePolicy) ((ManagedParentQueue)

0 commit comments

Comments
 (0)