Put error message from inside the process into the exception that is thrown when the process doesn't start correctly. (#45846) (#45875)

This commit is contained in:
Przemysław Witek 2019-08-23 07:02:50 +02:00 committed by GitHub
parent ba6d72ea9f
commit 2ed19b2c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -83,7 +83,8 @@ public class MemoryUsageEstimationProcessManager {
onProcessCrash(jobId, processHolder));
processHolder.process = process;
if (process.isProcessAlive() == false) {
String errorMsg = new ParameterizedMessage("[{}] Error while starting process", jobId).getFormattedMessage();
String errorMsg =
new ParameterizedMessage("[{}] Error while starting process: {}", jobId, process.readError()).getFormattedMessage();
throw ExceptionsHelper.serverError(errorMsg);
}
try {

View File

@ -95,6 +95,7 @@ public class MemoryUsageEstimationProcessManagerTests extends ESTestCase {
public void testRunJob_ProcessNotAlive() {
when(process.isProcessAlive()).thenReturn(false);
when(process.readError()).thenReturn("Error from inside the process");
processManager.runJobAsync(TASK_ID, dataFrameAnalyticsConfig, dataExtractorFactory, listener);
@ -103,8 +104,10 @@ public class MemoryUsageEstimationProcessManagerTests extends ESTestCase {
assertThat(exception.status(), equalTo(RestStatus.INTERNAL_SERVER_ERROR));
assertThat(exception.getMessage(), containsString(TASK_ID));
assertThat(exception.getMessage(), containsString("Error while starting process"));
assertThat(exception.getMessage(), containsString("Error from inside the process"));
verify(process).isProcessAlive();
verify(process).readError();
verifyNoMoreInteractions(process, listener);
}