Skip to content

Commit c6db73b

Browse files
committed
[ML] Prevent notifications on deletion of a non existent job (#35337)
1 parent 15689c9 commit c6db73b

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.CategorizerState;
6666
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.ModelSnapshot;
6767
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.Quantiles;
68+
import org.elasticsearch.xpack.ml.job.JobManager;
6869
import org.elasticsearch.xpack.ml.job.persistence.JobDataDeleter;
6970
import org.elasticsearch.xpack.ml.job.persistence.JobResultsProvider;
7071
import org.elasticsearch.xpack.ml.notifications.Auditor;
@@ -137,6 +138,8 @@ protected void masterOperation(Task task, DeleteJobAction.Request request, Clust
137138
ActionListener<AcknowledgedResponse> listener) {
138139
logger.debug("Deleting job '{}'", request.getJobId());
139140

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

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

Lines changed: 7 additions & 0 deletions
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)