diff --git a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/CancelReindexDataStreamTransportAction.java b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/CancelReindexDataStreamTransportAction.java index c262f5444f5a9..825def432eae4 100644 --- a/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/CancelReindexDataStreamTransportAction.java +++ b/x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/CancelReindexDataStreamTransportAction.java @@ -90,23 +90,19 @@ private void cancelTaskOnThisNode(String persistentTaskId, ActionListener() { - @Override - public void onResponse(PersistentTasksCustomMetadata.PersistentTask persistentTask) { - // Calling unregister removes the task from the /_tasks list - taskManager.unregister(runningTask); - listener.onResponse(AcknowledgedResponse.TRUE); - } + persistentTasksService.sendRemoveRequest(persistentTaskId, TimeValue.MAX_VALUE, new ActionListener<>() { + @Override + public void onResponse(PersistentTasksCustomMetadata.PersistentTask persistentTask) { + // Calling unregister removes the task from the /_tasks list + taskManager.unregister(runningTask); + listener.onResponse(AcknowledgedResponse.TRUE); + } - @Override - public void onFailure(Exception e) { - listener.onFailure(e); - } + @Override + public void onFailure(Exception e) { + listener.onFailure(e); } - ); + }); } }