From c117ae7a6ef4d83b4fd6d1e674ce0b9533d70bf3 Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Fri, 8 May 2020 18:04:24 +0300 Subject: [PATCH] [7.x][ML] Force stopping stopped DF analytics should succeed (#56421) (#56424) Force stopping a DF analytics job whose config exists and that is stopped should succeed. This was broken by #56360. Closes #56414 Backport of #56421 --- .../TransportStopDataFrameAnalyticsAction.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDataFrameAnalyticsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDataFrameAnalyticsAction.java index 41cfcef56d9..ac99707484a 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDataFrameAnalyticsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDataFrameAnalyticsAction.java @@ -154,11 +154,16 @@ public class TransportStopDataFrameAnalyticsAction ExpandedIdsMatcher expandedIdsMatcher = new ExpandedIdsMatcher(tokens, request.allowNoMatch()); expandedIdsMatcher.filterMatchedIds(startedIds); if (expandedIdsMatcher.hasUnmatchedIds()) { - matchingIdsListener.onFailure(ExceptionsHelper.missingDataFrameAnalytics(expandedIdsMatcher.unmatchedIdsString())); - return; + // There are expressions that did not match any started task. + // If there are no configs for those either, we should error. + // We check this by trying a get with the unmatched expressions. + configProvider.getMultiple(expandedIdsMatcher.unmatchedIdsString(), request.allowNoMatch(), ActionListener.wrap( + configs -> matchingIdsListener.onResponse(MlStrings.findMatching(tokens, startedIds)), + matchingIdsListener::onFailure + )); + } else { + matchingIdsListener.onResponse(MlStrings.findMatching(tokens, startedIds)); } - Set matchingStartedIds = MlStrings.findMatching(tokens, startedIds); - matchingIdsListener.onResponse(matchingStartedIds); } private void normalStop(Task task, StopDataFrameAnalyticsAction.Request request,