YARN-9569. Auto-created leaf queues do not honor cluster-wide min/max memory/vcores. Contributed by Craig Condit.

This commit is contained in:
Suma Shivaprasad 2019-06-10 14:33:24 -07:00
parent 0d160a0ba8
commit 9191e08f0a
3 changed files with 38 additions and 8 deletions

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerDynamicEditException;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common
@ -200,6 +201,13 @@ public abstract class AbstractManagedParentQueue extends ParentQueue {
CapacitySchedulerConfiguration leafQueueConfigs = new CapacitySchedulerConfiguration leafQueueConfigs = new
CapacitySchedulerConfiguration(new Configuration(false), false); CapacitySchedulerConfiguration(new Configuration(false), false);
String prefix = YarnConfiguration.RESOURCE_TYPES + ".";
Map<String, String> rtProps = csContext
.getConfiguration().getPropsWithPrefix(prefix);
for (Map.Entry<String, String> entry : rtProps.entrySet()) {
leafQueueConfigs.set(prefix + entry.getKey(), entry.getValue());
}
SortedMap<String, String> sortedConfigs = sortCSConfigurations(); SortedMap<String, String> sortedConfigs = sortCSConfigurations();
SortedMap<String, String> templateConfigs = getConfigurationsWithPrefix SortedMap<String, String> templateConfigs = getConfigurationsWithPrefix
(sortedConfigs, configPrefix); (sortedConfigs, configPrefix);

View File

@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.security.GroupMappingServiceProvider; import org.apache.hadoop.security.GroupMappingServiceProvider;
import org.apache.hadoop.security.ShellBasedUnixGroupsMapping; import org.apache.hadoop.security.ShellBasedUnixGroupsMapping;
@ -189,7 +190,7 @@ public class TestCapacitySchedulerAutoCreatedQueueBase {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); CapacitySchedulerConfiguration conf = setupSchedulerConfiguration();
setupQueueConfiguration(conf); setupQueueConfiguration(conf);
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
ResourceScheduler.class); ResourceScheduler.class);
@ -494,8 +495,22 @@ public class TestCapacitySchedulerAutoCreatedQueueBase {
return queueMappings; return queueMappings;
} }
protected CapacitySchedulerConfiguration setupSchedulerConfiguration() {
Configuration schedConf = new Configuration();
schedConf.setInt(YarnConfiguration.RESOURCE_TYPES
+ ".vcores.minimum-allocation", 1);
schedConf.setInt(YarnConfiguration.RESOURCE_TYPES
+ ".vcores.maximum-allocation", 8);
schedConf.setInt(YarnConfiguration.RESOURCE_TYPES
+ ".memory-mb.minimum-allocation", 1024);
schedConf.setInt(YarnConfiguration.RESOURCE_TYPES
+ ".memory-mb.maximum-allocation", 16384);
return new CapacitySchedulerConfiguration(schedConf);
}
protected MockRM setupSchedulerInstance() throws Exception { protected MockRM setupSchedulerInstance() throws Exception {
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(); CapacitySchedulerConfiguration conf = setupSchedulerConfiguration();
setupQueueConfiguration(conf); setupQueueConfiguration(conf);
conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class,
ResourceScheduler.class); ResourceScheduler.class);
@ -579,6 +594,14 @@ public class TestCapacitySchedulerAutoCreatedQueueBase {
autoCreatedLeafQueue.getMaxApplicationsPerUser()); autoCreatedLeafQueue.getMaxApplicationsPerUser());
} }
protected void validateContainerLimits(
AutoCreatedLeafQueue autoCreatedLeafQueue) {
assertEquals(8,
autoCreatedLeafQueue.getMaximumAllocation().getVirtualCores());
assertEquals(16384,
autoCreatedLeafQueue.getMaximumAllocation().getMemorySize());
}
protected void validateInitialQueueEntitlement(CSQueue parentQueue, String protected void validateInitialQueueEntitlement(CSQueue parentQueue, String
leafQueueName, Map<String, Float> leafQueueName, Map<String, Float>
expectedTotalChildQueueAbsCapacityByLabel, expectedTotalChildQueueAbsCapacityByLabel,

View File

@ -132,6 +132,7 @@ public class TestCapacitySchedulerAutoQueueCreation
expectedChildQueueAbsCapacity, accessibleNodeLabelsOnC); expectedChildQueueAbsCapacity, accessibleNodeLabelsOnC);
validateUserAndAppLimits(autoCreatedLeafQueue, 1000, 1000); validateUserAndAppLimits(autoCreatedLeafQueue, 1000, 1000);
validateContainerLimits(autoCreatedLeafQueue);
assertTrue(autoCreatedLeafQueue assertTrue(autoCreatedLeafQueue
.getOrderingPolicy() instanceof FairOrderingPolicy); .getOrderingPolicy() instanceof FairOrderingPolicy);
@ -256,8 +257,7 @@ public class TestCapacitySchedulerAutoQueueCreation
throws Exception { throws Exception {
CapacityScheduler newCS = new CapacityScheduler(); CapacityScheduler newCS = new CapacityScheduler();
try { try {
CapacitySchedulerConfiguration newConf = CapacitySchedulerConfiguration newConf = setupSchedulerConfiguration();
new CapacitySchedulerConfiguration();
setupQueueConfiguration(newConf); setupQueueConfiguration(newConf);
newConf.setAutoCreateChildQueueEnabled(C, false); newConf.setAutoCreateChildQueueEnabled(C, false);
@ -285,8 +285,7 @@ public class TestCapacitySchedulerAutoQueueCreation
throws Exception { throws Exception {
CapacityScheduler newCS = new CapacityScheduler(); CapacityScheduler newCS = new CapacityScheduler();
try { try {
CapacitySchedulerConfiguration newConf = CapacitySchedulerConfiguration newConf = setupSchedulerConfiguration();
new CapacitySchedulerConfiguration();
setupQueueConfiguration(newConf); setupQueueConfiguration(newConf);
newConf.setAutoCreatedLeafQueueConfigCapacity(A1, A1_CAPACITY / 10); newConf.setAutoCreatedLeafQueueConfigCapacity(A1, A1_CAPACITY / 10);
newConf.setAutoCreateChildQueueEnabled(A1, true); newConf.setAutoCreateChildQueueEnabled(A1, true);
@ -315,8 +314,7 @@ public class TestCapacitySchedulerAutoQueueCreation
throws Exception { throws Exception {
CapacityScheduler newCS = new CapacityScheduler(); CapacityScheduler newCS = new CapacityScheduler();
try { try {
CapacitySchedulerConfiguration newConf = CapacitySchedulerConfiguration newConf = setupSchedulerConfiguration();
new CapacitySchedulerConfiguration();
setupQueueConfiguration(newConf); setupQueueConfiguration(newConf);
newConf.setAutoCreatedLeafQueueConfigCapacity(A, A_CAPACITY / 10); newConf.setAutoCreatedLeafQueueConfigCapacity(A, A_CAPACITY / 10);
newConf.setAutoCreateChildQueueEnabled(A, true); newConf.setAutoCreateChildQueueEnabled(A, true);
@ -773,6 +771,7 @@ public class TestCapacitySchedulerAutoQueueCreation
validateCapacities(user3Queue, 0.3f, 0.09f, 0.4f,0.2f); validateCapacities(user3Queue, 0.3f, 0.09f, 0.4f,0.2f);
validateUserAndAppLimits(user3Queue, 900, 900); validateUserAndAppLimits(user3Queue, 900, 900);
validateContainerLimits(user3Queue);
GuaranteedOrZeroCapacityOverTimePolicy autoCreatedQueueManagementPolicy = GuaranteedOrZeroCapacityOverTimePolicy autoCreatedQueueManagementPolicy =
(GuaranteedOrZeroCapacityOverTimePolicy) ((ManagedParentQueue) (GuaranteedOrZeroCapacityOverTimePolicy) ((ManagedParentQueue)