Skip to content

Commit 126b548

Browse files
committed
Job task ceasing to exist part way through close should not be an error
A check for this situation when closing multiple jobs or stopping multiple datafeeds was added in elastic#38113. Later the wildcard requirement was removed for jobs in elastic#49367. But the wildcard requirement really should have been removed for both jobs and datafeeds, as they both having the same semantics that closing or stopping one that's already closed/stopped is not an error. This commit removes the wildcard condition for jobs.
1 parent 343bb81 commit 126b548

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

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

+3-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.cluster.ClusterState;
2323
import org.elasticsearch.cluster.node.DiscoveryNodes;
2424
import org.elasticsearch.cluster.service.ClusterService;
25-
import org.elasticsearch.common.Strings;
2625
import org.elasticsearch.common.inject.Inject;
2726
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
2827
import org.elasticsearch.common.util.concurrent.AtomicArray;
@@ -392,8 +391,7 @@ protected void taskOperation(CloseJobAction.Request request, JobTask jobTask, Ac
392391
threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME).execute(new AbstractRunnable() {
393392
@Override
394393
public void onFailure(Exception e) {
395-
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException
396-
&& Strings.isAllOrWildcard(request.getJobId())) {
394+
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException) {
397395
logger.trace(
398396
() -> new ParameterizedMessage(
399397
"[{}] [{}] failed to close job due to resource not found exception",
@@ -416,8 +414,7 @@ protected void doRun() {
416414
}
417415
});
418416
}, e -> {
419-
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException
420-
&& Strings.isAllOrWildcard(request.getJobId())) {
417+
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException) {
421418
logger.trace(
422419
() -> new ParameterizedMessage(
423420
"[{}] [{}] failed to update job to closing due to resource not found exception",
@@ -481,8 +478,7 @@ public void onResponse(PersistentTasksCustomMetadata.PersistentTask<?> task) {
481478
@Override
482479
public void onFailure(Exception e) {
483480
final int slot = counter.incrementAndGet();
484-
if ((ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException &&
485-
Strings.isAllOrWildcard(new String[]{request.getJobId()})) == false) {
481+
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException == false) {
486482
failures.set(slot - 1, e);
487483
}
488484
if (slot == numberOfJobs) {

0 commit comments

Comments
 (0)