[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
This commit is contained in:
Dimitris Athanasiou 2020-05-08 18:04:24 +03:00 committed by GitHub
parent 8e9b69bfd7
commit c117ae7a6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -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<String> matchingStartedIds = MlStrings.findMatching(tokens, startedIds);
matchingIdsListener.onResponse(matchingStartedIds);
}
private void normalStop(Task task, StopDataFrameAnalyticsAction.Request request,