From 2ed19b2c817fb4068888fb6246d3fda08d0460e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Witek?= Date: Fri, 23 Aug 2019 07:02:50 +0200 Subject: [PATCH] Put error message from inside the process into the exception that is thrown when the process doesn't start correctly. (#45846) (#45875) --- .../dataframe/process/MemoryUsageEstimationProcessManager.java | 3 ++- .../process/MemoryUsageEstimationProcessManagerTests.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManager.java index fac084c0fc8..00d8c15e418 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManager.java @@ -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 { diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManagerTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManagerTests.java index 82532ca430f..5a647c8178b 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManagerTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/process/MemoryUsageEstimationProcessManagerTests.java @@ -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); }