Skip to content

Commit

Permalink
Job task ceasing to exist part way through close should not be an error
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
droberts195 committed Jul 19, 2021
1 parent 343bb81 commit 126b548
Showing 1 changed file with 3 additions and 7 deletions.
Expand Up @@ -22,7 +22,6 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.AtomicArray;
Expand Down Expand Up @@ -392,8 +391,7 @@ protected void taskOperation(CloseJobAction.Request request, JobTask jobTask, Ac
threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME).execute(new AbstractRunnable() {
@Override
public void onFailure(Exception e) {
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException
&& Strings.isAllOrWildcard(request.getJobId())) {
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException) {
logger.trace(
() -> new ParameterizedMessage(
"[{}] [{}] failed to close job due to resource not found exception",
Expand All @@ -416,8 +414,7 @@ protected void doRun() {
}
});
}, e -> {
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException
&& Strings.isAllOrWildcard(request.getJobId())) {
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException) {
logger.trace(
() -> new ParameterizedMessage(
"[{}] [{}] failed to update job to closing due to resource not found exception",
Expand Down Expand Up @@ -481,8 +478,7 @@ public void onResponse(PersistentTasksCustomMetadata.PersistentTask<?> task) {
@Override
public void onFailure(Exception e) {
final int slot = counter.incrementAndGet();
if ((ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException &&
Strings.isAllOrWildcard(new String[]{request.getJobId()})) == false) {
if (ExceptionsHelper.unwrapCause(e) instanceof ResourceNotFoundException == false) {
failures.set(slot - 1, e);
}
if (slot == numberOfJobs) {
Expand Down

0 comments on commit 126b548

Please sign in to comment.