Skip to content

Commit 9c87f39

Browse files
szilard-nemethtomicooler
authored andcommitted
COMPX-10150: YARN-11016. Queue weight is incorrectly reset to zero. Contributed by Andras Gyori
Change-Id: Icf6e0ada35837218673628a1c9a591f7639b4a47
1 parent cd087bd commit 9c87f39

File tree

2 files changed

+47
-1
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src

2 files changed

+47
-1
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/QueueCapacities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public void clearConfigurableFields() {
327327
_set(label, CapacityType.MAX_CAP, 0);
328328
_set(label, CapacityType.ABS_CAP, 0);
329329
_set(label, CapacityType.ABS_MAX_CAP, 0);
330-
_set(label, CapacityType.WEIGHT, 0);
330+
_set(label, CapacityType.WEIGHT, -1);
331331
}
332332
} finally {
333333
writeLock.unlock();

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
2727
import org.apache.hadoop.yarn.api.records.ContainerId;
2828
import org.apache.hadoop.yarn.api.records.NodeId;
29+
import org.apache.hadoop.yarn.api.records.Resource;
2930
import org.apache.hadoop.yarn.conf.YarnConfiguration;
3031
import org.apache.hadoop.yarn.server.resourcemanager.MockAM;
3132
import org.apache.hadoop.yarn.server.resourcemanager.MockNM;
@@ -38,6 +39,7 @@
3839
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
3940
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
4041
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerState;
42+
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceLimits;
4143
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
4244
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport;
4345
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler;
@@ -74,6 +76,28 @@ public static <E> Set<E> toSet(E... elements) {
7476
return set;
7577
}
7678

79+
public static CapacitySchedulerConfiguration getConfigWithInheritedAccessibleNodeLabel(
80+
Configuration config) {
81+
CapacitySchedulerConfiguration conf = new CapacitySchedulerConfiguration(
82+
config);
83+
84+
// Define top-level queues
85+
conf.setQueues(CapacitySchedulerConfiguration.ROOT,
86+
new String[] { "a"});
87+
88+
conf.setCapacityByLabel(A, RMNodeLabelsManager.NO_LABEL, 100f);
89+
conf.setCapacityByLabel(A, "newLabel", 100f);
90+
conf.setAccessibleNodeLabels(A, toSet("newLabel"));
91+
conf.setAllowZeroCapacitySum(A, true);
92+
93+
// Define 2nd-level queues
94+
conf.setQueues(A, new String[] { "a1" });
95+
conf.setCapacityByLabel(A1, RMNodeLabelsManager.NO_LABEL, 100f);
96+
97+
return conf;
98+
}
99+
100+
77101
/*
78102
* Queue structure:
79103
* root (*)
@@ -368,6 +392,28 @@ public void testChildAccessibleNodeLabelsWeightMode() throws Exception {
368392
rm.close();
369393
}
370394

395+
/**
396+
* Tests whether weight is correctly reset to -1. See YARN-11016 for further details.
397+
* @throws IOException if reinitialization fails
398+
*/
399+
@Test()
400+
public void testAccessibleNodeLabelsInheritanceNoWeightMode() throws IOException {
401+
CapacitySchedulerConfiguration newConf = getConfigWithInheritedAccessibleNodeLabel(conf);
402+
403+
MockRM rm = new MockRM(newConf);
404+
CapacityScheduler cs =
405+
(CapacityScheduler) rm.getRMContext().getScheduler();
406+
407+
Resource clusterResource = Resource.newInstance(1024, 2);
408+
cs.getRootQueue().updateClusterResource(clusterResource, new ResourceLimits(clusterResource));
409+
410+
try {
411+
cs.reinitialize(newConf, rm.getRMContext());
412+
} catch (Exception e) {
413+
Assert.fail("Reinitialization failed with " + e);
414+
}
415+
}
416+
371417
@Test
372418
public void testQueueInfoWeight() throws Exception {
373419
MockRM rm = new MockRM(conf);

0 commit comments

Comments
 (0)