diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java index 6631d3a271b..6caa4185477 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java @@ -1496,16 +1496,20 @@ public class ContainerImpl implements Container { static class KillOnNewTransition extends ContainerDoneTransition { @Override public void transition(ContainerImpl container, ContainerEvent event) { - ContainerKillEvent killEvent = (ContainerKillEvent) event; - container.exitCode = killEvent.getContainerExitStatus(); - container.addDiagnostics(killEvent.getDiagnostic(), "\n"); - container.addDiagnostics("Container is killed before being launched.\n"); - container.metrics.killedContainer(); - NMAuditLogger.logSuccess(container.user, - AuditConstants.FINISH_KILLED_CONTAINER, "ContainerImpl", - container.containerId.getApplicationAttemptId().getApplicationId(), - container.containerId); - super.transition(container, event); + if (container.recoveredStatus == RecoveredContainerStatus.COMPLETED) { + container.sendFinishedEvents(); + } else { + ContainerKillEvent killEvent = (ContainerKillEvent) event; + container.exitCode = killEvent.getContainerExitStatus(); + container.addDiagnostics(killEvent.getDiagnostic(), "\n"); + container.addDiagnostics("Container is killed before being launched.\n"); + container.metrics.killedContainer(); + NMAuditLogger.logSuccess(container.user, + AuditConstants.FINISH_KILLED_CONTAINER, "ContainerImpl", + container.containerId.getApplicationAttemptId().getApplicationId(), + container.containerId); + super.transition(container, event); + } } }