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 @@ private RMContainer recoverAndCreateContainer(NMContainerStatus status,
container.setVersion(status.getVersion());
ApplicationAttemptId attemptId =
container.getId().getApplicationAttemptId();
String labelExpression = status.getNodeLabelExpression();
// If NodeLabel is disabled but recovered container has label expression
// its better to suppress that and considered as default label.
if (!status.getNodeLabelExpression().isEmpty() && !YarnConfiguration
.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);
RMContainer rmContainer = new RMContainerImpl(container,
SchedulerRequestKey.extractFrom(container), attemptId, node.getNodeID(),
applications.get(attemptId.getApplicationId()).getUser(), rmContext,
status.getCreationTime(), status.getNodeLabelExpression());
return rmContainer;
}

View File

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

View File

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