From 72f5e9297297e069f9dc1aa5c3234c1d8447cafa Mon Sep 17 00:00:00 2001 From: David Roberts Date: Thu, 30 Mar 2017 10:33:56 +0100 Subject: [PATCH] [ML] Adjust error to make sense for FAILED as well as CLOSED jobs (elastic/x-pack-elasticsearch#888) Previously trying to perform an operation on a FAILED job would tell you that it hadn't been opened. This was very confusing if you knew very well you'd just opened the job. Relates elastic/x-pack-elasticsearch#879 Original commit: elastic/x-pack-elasticsearch@2dbe41caaaeb49b1302351111dd7488c988692ac --- .../elasticsearch/xpack/ml/action/StartDatafeedAction.java | 2 +- .../elasticsearch/xpack/ml/action/TransportJobTaskAction.java | 4 ++-- .../elasticsearch/license/MachineLearningLicensingTests.java | 2 +- .../xpack/ml/action/StartDatafeedActionTests.java | 2 +- .../xpack/ml/integration/MlRestTestStateCleaner.java | 2 +- .../elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java | 2 +- .../xpack/ml/integration/MlRestTestStateCleaner.java | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/StartDatafeedAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/StartDatafeedAction.java index 2fd11d56841..2d0cd26c6e4 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/StartDatafeedAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/StartDatafeedAction.java @@ -472,7 +472,7 @@ public class StartDatafeedAction JobState jobState = MlMetadata.getJobState(datafeed.getJobId(), tasks); if (jobState != JobState.OPENED) { throw ExceptionsHelper.conflictStatusException("cannot start datafeed [" + datafeedId + "] because job [" + job.getId() + - "] hasn't been opened"); + "] is not open"); } PersistentTask datafeedTask = MlMetadata.getDatafeedTask(datafeedId, tasks); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java index 23b71eefbcc..e6974c27f72 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/TransportJobTaskAction.java @@ -63,7 +63,7 @@ public abstract class TransportJobTaskAction jobTask = MlMetadata.getJobTask(jobId, tasks); if (jobTask == null || jobTask.isAssigned() == false) { - String message = "Cannot perform requested action because job [" + jobId + "] hasn't been opened"; + String message = "Cannot perform requested action because job [" + jobId + "] is not open"; listener.onFailure(ExceptionsHelper.conflictStatusException(message)); } else { request.setNodes(jobTask.getExecutorNode()); @@ -81,7 +81,7 @@ public abstract class TransportJobTaskAction StartDatafeedAction.validate("foo-datafeed", mlMetadata2, tasks)); - assertThat(e.getMessage(), equalTo("cannot start datafeed [foo-datafeed] because job [job_id] hasn't been opened")); + assertThat(e.getMessage(), equalTo("cannot start datafeed [foo-datafeed] because job [job_id] is not open")); } public void testValidate_dataFeedAlreadyStarted() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java index 52edf7daa79..a085c629fd5 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java @@ -84,7 +84,7 @@ public class MlRestTestStateCleaner { logger.error("Got status code " + statusCode + " when closing job " + jobId); } } catch (Exception e1) { - if (e1.getMessage().contains("because job [" + jobId + "] hasn't been opened")) { + if (e1.getMessage().contains("because job [" + jobId + "] is not open")) { logger.debug("job [" + jobId + "] has already been closed", e1); } else { logger.warn("failed to close job [" + jobId + "]. Forcing closed", e1); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index 27f5d2411fa..c403811b0e2 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -293,7 +293,7 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { client.execute(CloseJobAction.INSTANCE, closeRequest).get(); assertTrue(response.isClosed()); } catch (Exception e1) { - if (e1.getMessage().contains("because job [" + jobId + "] hasn't been opened")) { + if (e1.getMessage().contains("because job [" + jobId + "] is not open")) { logger.debug("job [" + jobId + "] has already been closed", e1); } else { try { diff --git a/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java b/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java index 52edf7daa79..a085c629fd5 100644 --- a/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java +++ b/qa/smoke-test-ml-with-security/src/test/java/org/elasticsearch/xpack/ml/integration/MlRestTestStateCleaner.java @@ -84,7 +84,7 @@ public class MlRestTestStateCleaner { logger.error("Got status code " + statusCode + " when closing job " + jobId); } } catch (Exception e1) { - if (e1.getMessage().contains("because job [" + jobId + "] hasn't been opened")) { + if (e1.getMessage().contains("because job [" + jobId + "] is not open")) { logger.debug("job [" + jobId + "] has already been closed", e1); } else { logger.warn("failed to close job [" + jobId + "]. Forcing closed", e1);