From 3829a83864dc2979ec526abeeff69245b51ec887 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Mon, 12 Dec 2016 12:50:40 +0000 Subject: [PATCH] Check job exists and return a 404 on flush (elastic/elasticsearch#529) Original commit: elastic/x-pack-elasticsearch@7721d4510a2d062a586156ee660ec985995249bf --- .../elasticsearch/xpack/prelert/action/FlushJobAction.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/action/FlushJobAction.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/action/FlushJobAction.java index 0b30f570d2e..9cbf852da2c 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/action/FlushJobAction.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/action/FlushJobAction.java @@ -30,6 +30,7 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.prelert.PrelertPlugin; import org.elasticsearch.xpack.prelert.job.Job; import org.elasticsearch.xpack.prelert.job.manager.AutodetectProcessManager; +import org.elasticsearch.xpack.prelert.job.manager.JobManager; import org.elasticsearch.xpack.prelert.job.process.autodetect.params.InterimResultsParams; import org.elasticsearch.xpack.prelert.job.process.autodetect.params.TimeRange; import org.elasticsearch.xpack.prelert.utils.ExceptionsHelper; @@ -226,20 +227,24 @@ public class FlushJobAction extends Action listener) { threadPool.executor(PrelertPlugin.THREAD_POOL_NAME).execute(() -> { try { + jobManager.getJobOrThrowIfUnknown(request.getJobId()); + InterimResultsParams.Builder paramsBuilder = InterimResultsParams.builder(); paramsBuilder.calcInterim(request.getCalcInterim()); if (request.getAdvanceTime() != null) {