diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 9f0f702a10..7a8131d87f 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -164,6 +164,9 @@ Release 2.3.0 - UNRELEASED current attempt instead of the attempt passed as argument (Omkar Vinit Joshi via bikas) + YARN-1053. Diagnostic message from ContainerExitEvent is ignored in + ContainerImpl (Omkar Vinit Joshi via bikas) + Release 2.2.1 - UNRELEASED INCOMPATIBLE CHANGES 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 34c0cc66dd..486f3ce00c 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 @@ -18,7 +18,6 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager.container; -import java.io.IOException; import java.net.URISyntaxException; import java.nio.ByteBuffer; import java.util.ArrayList; @@ -687,6 +686,10 @@ public ExitedWithFailureTransition(boolean clCleanupRequired) { public void transition(ContainerImpl container, ContainerEvent event) { ContainerExitEvent exitEvent = (ContainerExitEvent) event; container.exitCode = exitEvent.getExitCode(); + if (exitEvent.getDiagnosticInfo() != null) { + container.diagnostics.append(exitEvent.getDiagnosticInfo()) + .append('\n'); + } // TODO: Add containerWorkDir to the deletion service. // TODO: Add containerOuputDir to the deletion service. @@ -806,6 +809,10 @@ static class ContainerKilledTransition implements public void transition(ContainerImpl container, ContainerEvent event) { ContainerExitEvent exitEvent = (ContainerExitEvent) event; container.exitCode = exitEvent.getExitCode(); + if (exitEvent.getDiagnosticInfo() != null) { + container.diagnostics.append(exitEvent.getDiagnosticInfo()) + .append('\n'); + } // The process/process-grp is killed. Decrement reference counts and // cleanup resources diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java index ebc400abb0..addb28d83a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java @@ -55,6 +55,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResourceType; import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; @@ -844,9 +845,13 @@ public void containerResourcesCleanup() { } public void containerFailed(int exitCode) { + String diagnosticMsg = "Container completed with exit code " + exitCode; c.handle(new ContainerExitEvent(cId, ContainerEventType.CONTAINER_EXITED_WITH_FAILURE, exitCode, - "Container completed with exit code " + exitCode)); + diagnosticMsg)); + ContainerStatus containerStatus = c.cloneAndGetContainerStatus(); + assert containerStatus.getDiagnostics().contains(diagnosticMsg); + assert containerStatus.getExitStatus() == exitCode; drainDispatcherEvents(); } @@ -857,9 +862,13 @@ public void killContainer() { public void containerKilledOnRequest() { int exitCode = ExitCode.FORCE_KILLED.getExitCode(); + String diagnosticMsg = "Container completed with exit code " + exitCode; c.handle(new ContainerExitEvent(cId, ContainerEventType.CONTAINER_KILLED_ON_REQUEST, exitCode, - "Container completed with exit code " + exitCode)); + diagnosticMsg)); + ContainerStatus containerStatus = c.cloneAndGetContainerStatus(); + assert containerStatus.getDiagnostics().contains(diagnosticMsg); + assert containerStatus.getExitStatus() == exitCode; drainDispatcherEvents(); }