Skip to content

Commit 9494e04

Browse files
authored
[ML] Prevent notifications on deletion of a non existent job (#35337)
1 parent 8a85251 commit 9494e04

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.CategorizerState;
6565
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.ModelSnapshot;
6666
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.Quantiles;
67+
import org.elasticsearch.xpack.ml.job.JobManager;
6768
import org.elasticsearch.xpack.ml.job.persistence.JobDataDeleter;
6869
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
6970
import org.elasticsearch.xpack.ml.notifications.Auditor;
@@ -136,6 +137,8 @@ protected void masterOperation(Task task, DeleteJobAction.Request request, Clust
136137
ActionListener<AcknowledgedResponse> listener) {
137138
logger.debug("Deleting job '{}'", request.getJobId());
138139

140+
JobManager.getJobOrThrowIfUnknown(request.getJobId(), state);
141+
139142
TaskId taskId = new TaskId(clusterService.localNode().getId(), task.getId());
140143
ParentTaskAssigningClient parentTaskClient = new ParentTaskAssigningClient(client, taskId);
141144

x-pack/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yml

+7
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@
460460
}
461461
- match: { analysis_limits.model_memory_limit: "30mb" }
462462

463+
---
464+
"Test delete job that does not exist":
465+
- do:
466+
catch: missing
467+
xpack.ml.delete_job:
468+
job_id: not-a-job
469+
463470
---
464471
"Test delete job that is referred by a datafeed":
465472
- do:

0 commit comments

Comments
 (0)