YARN-6872. [Addendum patch] Ensure apps could run given NodeLabels are disabled post RM switchover/restart. Contributed by Sunil G

This commit is contained in:
Jian He 2017-08-02 00:03:25 -07:00
parent 3a0b84d9c9
commit f9139ac8f6
3 changed files with 8 additions and 18 deletions

View File

@ -519,20 +519,10 @@ public abstract class AbstractYarnScheduler
container.setVersion(status.getVersion()); container.setVersion(status.getVersion());
ApplicationAttemptId attemptId = ApplicationAttemptId attemptId =
container.getId().getApplicationAttemptId(); container.getId().getApplicationAttemptId();
String labelExpression = status.getNodeLabelExpression(); RMContainer rmContainer = new RMContainerImpl(container,
// If NodeLabel is disabled but recovered container has label expression SchedulerRequestKey.extractFrom(container), attemptId, node.getNodeID(),
// its better to suppress that and considered as default label. applications.get(attemptId.getApplicationId()).getUser(), rmContext,
if (!status.getNodeLabelExpression().isEmpty() && !YarnConfiguration status.getCreationTime(), status.getNodeLabelExpression());
.areNodeLabelsEnabled(rmContext.getYarnConfiguration())) {
labelExpression = RMNodeLabelsManager.NO_LABEL;
}
RMContainer rmContainer =
new RMContainerImpl(container,
SchedulerRequestKey.extractFrom(container), attemptId,
node.getNodeID(), applications.get(
attemptId.getApplicationId()).getUser(), rmContext,
status.getCreationTime(), labelExpression);
return rmContainer; return rmContainer;
} }

View File

@ -524,7 +524,7 @@ public class AppSchedulingInfo {
this.placesBlacklistedByApp = appInfo.getBlackList(); this.placesBlacklistedByApp = appInfo.getBlackList();
} }
public void recoverContainer(RMContainer rmContainer) { public void recoverContainer(RMContainer rmContainer, String partition) {
try { try {
this.writeLock.lock(); this.writeLock.lock();
QueueMetrics metrics = queue.getMetrics(); QueueMetrics metrics = queue.getMetrics();
@ -540,8 +540,8 @@ public class AppSchedulingInfo {
return; return;
} }
metrics.allocateResources(rmContainer.getNodeLabelExpression(), metrics.allocateResources(partition, user, 1,
user, 1, rmContainer.getAllocatedResource(), false); rmContainer.getAllocatedResource(), false);
} finally { } finally {
this.writeLock.unlock(); this.writeLock.unlock();
} }

View File

@ -1103,7 +1103,7 @@ public class SchedulerApplicationAttempt implements SchedulableEntity {
try { try {
writeLock.lock(); writeLock.lock();
// recover app scheduling info // recover app scheduling info
appSchedulingInfo.recoverContainer(rmContainer); appSchedulingInfo.recoverContainer(rmContainer, node.getPartition());
if (rmContainer.getState().equals(RMContainerState.COMPLETED)) { if (rmContainer.getState().equals(RMContainerState.COMPLETED)) {
return; return;