[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@25fb18ed0b
This commit is contained in:
Dimitris Athanasiou 2017-05-04 15:17:48 +01:00 committed by GitHub
parent eddc7a2147
commit 4241469c89
3 changed files with 30 additions and 2 deletions

View File

@ -362,7 +362,7 @@ public class MlMetadata implements MetaData.Custom {
PersistentTask<?> jobTask = getJobTask(jobId, tasks); PersistentTask<?> jobTask = getJobTask(jobId, tasks);
if (jobTask != null) { if (jobTask != null) {
throw ExceptionsHelper.conflictStatusException("Cannot delete job [" + jobId + "] because the job is " throw ExceptionsHelper.conflictStatusException("Cannot delete job [" + jobId + "] because the job is "
+ jobTask.getStatus()); + ((JobTaskStatus) jobTask.getStatus()).getState());
} }
Job.Builder jobBuilder = new Job.Builder(job); Job.Builder jobBuilder = new Job.Builder(job);
jobBuilder.setDeleted(true); jobBuilder.setDeleted(true);

View File

@ -466,7 +466,7 @@ public class OpenJobAction extends Action<OpenJobAction.Request, OpenJobAction.R
case FAILED: case FAILED:
return true; return true;
default: default:
throw new IllegalStateException("Unexpected job state [" + jobState + "]"); throw new IllegalStateException("Unexpected job state [" + jobState.getState() + "]");
} }
} }

View File

@ -296,6 +296,34 @@
catch: /Cannot delete job \[jobs-crud-datafeed-job\] because datafeed \[jobs-crud-test-datafeed-1\] refers to it/ catch: /Cannot delete job \[jobs-crud-datafeed-job\] because datafeed \[jobs-crud-test-datafeed-1\] refers to it/
xpack.ml.delete_job: xpack.ml.delete_job:
job_id: jobs-crud-datafeed-job job_id: jobs-crud-datafeed-job
---
"Test delete job that is opened":
- do:
xpack.ml.put_job:
job_id: delete-opened-job
body: >
{
"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": "Test close job":