YARN-9984. FSPreemptionThread can cause NullPointerException while app is unregistered with containers running on a node. Contributed by Wilfred Spiegelenburg.

(cherry picked from commit 215f2052fc)
This commit is contained in:
Sunil G 2019-11-19 14:03:02 +05:30
parent b4f0c63a6a
commit f24d1fac35
1 changed files with 14 additions and 3 deletions

View File

@ -140,13 +140,17 @@ class FSPreemptionThread extends Thread {
for (RMContainer container : containers) { for (RMContainer container : containers) {
FSAppAttempt app = scheduler.getSchedulerApp( FSAppAttempt app = scheduler.getSchedulerApp(
container.getApplicationAttemptId()); container.getApplicationAttemptId());
LOG.info("Preempting container " + container + LOG.info("Preempting container " + container + " from queue: "
" from queue " + app.getQueueName()); + (app != null ? app.getQueueName() : "unknown"));
// If the app has unregistered while building the container list
// the app might be null, skip notifying the app
if (app != null) {
app.trackContainerForPreemption(container); app.trackContainerForPreemption(container);
} }
} }
} }
} }
}
} // End of iteration over RRs } // End of iteration over RRs
return containersToPreempt; return containersToPreempt;
} }
@ -204,6 +208,13 @@ class FSPreemptionThread extends Thread {
for (RMContainer container : containersToCheck) { for (RMContainer container : containersToCheck) {
FSAppAttempt app = FSAppAttempt app =
scheduler.getSchedulerApp(container.getApplicationAttemptId()); scheduler.getSchedulerApp(container.getApplicationAttemptId());
// If the app has unregistered while building the container list the app
// might be null, just skip this container: it should be cleaned up soon
if (app == null) {
LOG.info("Found container " + container + " on node "
+ node.getNodeName() + "without app, skipping preemption");
continue;
}
ApplicationId appId = app.getApplicationId(); ApplicationId appId = app.getApplicationId();
if (app.canContainerBePreempted(container, if (app.canContainerBePreempted(container,