|
6 | 6 | package org.elasticsearch.xpack.ml.action;
|
7 | 7 |
|
8 | 8 | import org.elasticsearch.ElasticsearchException;
|
| 9 | +import org.elasticsearch.ResourceNotFoundException; |
9 | 10 | import org.elasticsearch.action.ActionListener;
|
10 | 11 | import org.elasticsearch.action.ActionListenerResponseHandler;
|
11 | 12 | import org.elasticsearch.action.FailedNodeException;
|
|
17 | 18 | import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
18 | 19 | import org.elasticsearch.cluster.node.DiscoveryNodes;
|
19 | 20 | import org.elasticsearch.cluster.service.ClusterService;
|
| 21 | +import org.elasticsearch.common.Strings; |
20 | 22 | import org.elasticsearch.common.inject.Inject;
|
21 | 23 | import org.elasticsearch.common.io.stream.StreamInput;
|
22 | 24 | import org.elasticsearch.common.settings.Settings;
|
@@ -291,7 +293,12 @@ protected void taskOperation(CloseJobAction.Request request, TransportOpenJobAct
|
291 | 293 | threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME).execute(new AbstractRunnable() {
|
292 | 294 | @Override
|
293 | 295 | public void onFailure(Exception e) {
|
294 |
| - listener.onFailure(e); |
| 296 | + if (e instanceof ResourceNotFoundException && Strings.isAllOrWildcard(new String[]{request.getJobId()})) { |
| 297 | + jobTask.closeJob("close job (api)"); |
| 298 | + listener.onResponse(new CloseJobAction.Response(true)); |
| 299 | + } else { |
| 300 | + listener.onFailure(e); |
| 301 | + } |
295 | 302 | }
|
296 | 303 |
|
297 | 304 | @Override
|
@@ -356,7 +363,10 @@ public void onResponse(PersistentTasksCustomMetaData.PersistentTask<?> task) {
|
356 | 363 | @Override
|
357 | 364 | public void onFailure(Exception e) {
|
358 | 365 | final int slot = counter.incrementAndGet();
|
359 |
| - failures.set(slot - 1, e); |
| 366 | + if ((e instanceof ResourceNotFoundException && |
| 367 | + Strings.isAllOrWildcard(new String[]{request.getJobId()})) == false) { |
| 368 | + failures.set(slot - 1, e); |
| 369 | + } |
360 | 370 | if (slot == numberOfJobs) {
|
361 | 371 | sendResponseOrFailure(request.getJobId(), listener, failures);
|
362 | 372 | }
|
|
0 commit comments