-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Cancel reindex returns same response as GET #140626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| import org.elasticsearch.injection.guice.Inject; | ||
| import org.elasticsearch.tasks.CancellableTask; | ||
| import org.elasticsearch.tasks.TaskId; | ||
| import org.elasticsearch.tasks.TaskResult; | ||
| import org.elasticsearch.threadpool.ThreadPool; | ||
| import org.elasticsearch.transport.TransportService; | ||
|
|
||
|
|
@@ -80,7 +81,12 @@ protected void taskOperation( | |
| task, | ||
| CancelTasksRequest.DEFAULT_REASON, | ||
| request.waitForCompletion(), | ||
| ActionListener.wrap(ignored -> listener.onResponse(new CancelReindexTaskResponse()), listener::onFailure) | ||
| ActionListener.wrap(ignored -> { | ||
| final TaskResult completedTaskResult = request.waitForCompletion() | ||
| ? new TaskResult(true, task.taskInfo(clusterService.localNode().getId(), true)) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's a choice to be made here that we discussed on the meeting, detailing so we can make a concrete decision. firstly, context/existing art:
in terms of what we're doing here, I see two main choices to get what we want (a more fully-featured response on
other potential avenues:
stating preference:
attaching below two files so reviewers can diff what is returned in
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'm happy with what you have here. As discussed, I'm okay with not including the full response. I think I'm also okay with the times not matching up perfectly, especially as they're in different units. Reporting the correct value for |
||
| : null; | ||
| listener.onResponse(new CancelReindexTaskResponse(completedTaskResult)); | ||
| }, listener::onFailure) | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -99,7 +105,10 @@ protected CancelReindexResponse newResponse( | |
| } | ||
| } | ||
|
|
||
| final var response = new CancelReindexResponse(taskFailures, nodeExceptions); | ||
| final GetReindexResponse completedReindexResponse = tasks.isEmpty() | ||
| ? null | ||
| : tasks.getFirst().getCompletedTaskResult().map(GetReindexResponse::new).orElse(null); | ||
| final var response = new CancelReindexResponse(taskFailures, nodeExceptions, completedReindexResponse); | ||
| response.rethrowFailures("cancel_reindex"); // if we haven't handled any exception already, throw here | ||
| if (tasks.isEmpty()) { | ||
| throw reindexWithTaskIdNotFoundException(request.getTargetTaskId()); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
incoming yaml rest tests (next PR) will assert response more definitively
for now, just asserting the basics that are relevant for these tests