Skip to content

Commit 296c5de

Browse files
YARN-5873. RM crashes with NPE if generic application history is enabled. Contributed by Varun Saxena.
1 parent 04014c4 commit 296c5de

File tree

1 file changed

+6
-1
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer

1 file changed

+6
-1
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/RMContainerImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ public RMContainerImpl(Container container,
247247
YarnConfiguration
248248
.DEFAULT_APPLICATION_HISTORY_SAVE_NON_AM_CONTAINER_META_INFO);
249249

250-
rmContext.getRMApplicationHistoryWriter().containerStarted(this);
250+
if (container.getId() != null) {
251+
rmContext.getRMApplicationHistoryWriter().containerStarted(this);
252+
}
251253

252254
// If saveNonAMContainerMetaInfo is true, store system metrics for all
253255
// containers. If false, and if this container is marked as the AM, metrics
@@ -892,6 +894,9 @@ public void setContainerId(ContainerId containerId) {
892894
// container creation event to timeline service when id assigned.
893895
container.setId(containerId);
894896

897+
if (containerId != null) {
898+
rmContext.getRMApplicationHistoryWriter().containerStarted(this);
899+
}
895900
// If saveNonAMContainerMetaInfo is true, store system metrics for all
896901
// containers. If false, and if this container is marked as the AM, metrics
897902
// will still be published for this container, but that calculation happens

0 commit comments

Comments
 (0)