[ML] Index the audit notification before responding to a delete request (elastic/x-pack-elasticsearch#1150)
This change prevents the situation where cleanup of ML indices immediately
after deleting a job leaves the audit notification in limbo because the index
it was due to be indexed into has been deleted.
Relates elastic/x-pack-elasticsearch#1142
Original commit: elastic/x-pack-elasticsearch@300e9c36ce5d313429eedcbf3e8465443e891e48
@@ -278,8 +278,8 @@ public class JobManager extends AbstractComponent {
CheckedConsumer<Boolean, Exception> apiResponseHandler = jobDeleted -> {
if (jobDeleted) {
logger.info("Job [" + jobId + "] deleted.");
- actionListener.onResponse(new DeleteJobAction.Response(true));
auditor.info(jobId, Messages.getMessage(Messages.JOB_AUDIT_DELETED));
+ actionListener.onResponse(new DeleteJobAction.Response(true));
} else {
actionListener.onResponse(new DeleteJobAction.Response(false));
}
