From 4241469c89c7285938966bdc5da1b4430b01cdcc Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Thu, 4 May 2017 15:17:48 +0100 Subject: [PATCH] [ML] Correctly print job state when delete job fails (elastic/x-pack-elasticsearch#1310) relates elastic/x-pack-elasticsearch#1307 Original commit: elastic/x-pack-elasticsearch@25fb18ed0b2c6679bb93c99f2d21babdb118120a --- .../elasticsearch/xpack/ml/MlMetadata.java | 2 +- .../xpack/ml/action/OpenJobAction.java | 2 +- .../rest-api-spec/test/ml/jobs_crud.yaml | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java index d461307988a..93aee29592d 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java @@ -362,7 +362,7 @@ public class MlMetadata implements MetaData.Custom { PersistentTask jobTask = getJobTask(jobId, tasks); if (jobTask != null) { throw ExceptionsHelper.conflictStatusException("Cannot delete job [" + jobId + "] because the job is " - + jobTask.getStatus()); + + ((JobTaskStatus) jobTask.getStatus()).getState()); } Job.Builder jobBuilder = new Job.Builder(job); jobBuilder.setDeleted(true); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java index 455f9b690ba..7ea949f9b26 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/OpenJobAction.java @@ -466,7 +466,7 @@ public class OpenJobAction extends Action + { + "analysis_config" : { + "bucket_span": "1h", + "detectors" :[{"function":"count"}] + }, + "data_description" : { + "time_field":"time" + } + } + - match: { job_id: "delete-opened-job" } + + - do: + xpack.ml.open_job: + job_id: delete-opened-job + - match: { opened: true } + + - do: + catch: /Cannot delete job \[delete-opened-job\] because the job is opened/ + xpack.ml.delete_job: + job_id: delete-opened-job + --- "Test close job":