YARN-8465. Fixed docker container status for node manager restart.

Contributed by Shane Kumpf
This commit is contained in:
Eric Yang 2018-07-02 13:37:51 -04:00
parent fef20a446f
commit 5cc2541a16
3 changed files with 16 additions and 4 deletions

View File

@ -1027,7 +1027,6 @@ public void signalContainer(ContainerRuntimeContext ctx)
handleContainerKill(ctx, env, signal);
}
} catch (ContainerExecutionException e) {
LOG.warn("Signal docker container failed. Exception: ", e);
throw new ContainerExecutionException("Signal docker container failed",
e.getExitCode(), e.getOutput(), e.getErrorOutput());
}
@ -1201,7 +1200,8 @@ private void executeLivelinessCheck(ContainerRuntimeContext ctx)
if (!new File(procFs + File.separator + pid).exists()) {
String msg = "Liveliness check failed for PID: " + pid
+ ". Container may have already completed.";
throw new ContainerExecutionException(msg);
throw new ContainerExecutionException(msg,
PrivilegedOperation.ResultCode.INVALID_CONTAINER_PID.getValue());
}
}

View File

@ -53,6 +53,12 @@ public ContainerExecutionException(Throwable throwable) {
errorOutput = OUTPUT_UNSET;
}
public ContainerExecutionException(String message, int exitCode) {
super(message);
this.exitCode = exitCode;
this.output = OUTPUT_UNSET;
this.errorOutput = OUTPUT_UNSET;
}
public ContainerExecutionException(String message, int exitCode, String
output, String errorOutput) {

View File

@ -1492,7 +1492,7 @@ public void testContainerLivelinessFileExistsNoException() throws Exception {
runtime.signalContainer(builder.build());
}
@Test(expected = ContainerExecutionException.class)
@Test
public void testContainerLivelinessNoFileException() throws Exception {
DockerLinuxContainerRuntime runtime = new DockerLinuxContainerRuntime(
mockExecutor, mockCGroupsHandler);
@ -1501,7 +1501,13 @@ public void testContainerLivelinessNoFileException() throws Exception {
.setExecutionAttribute(PID, signalPid)
.setExecutionAttribute(SIGNAL, ContainerExecutor.Signal.NULL);
runtime.initialize(enableMockContainerExecutor(conf), null);
try {
runtime.signalContainer(builder.build());
} catch (ContainerExecutionException e) {
Assert.assertEquals(
PrivilegedOperation.ResultCode.INVALID_CONTAINER_PID.getValue(),
e.getExitCode());
}
}
@Test