Cancel reindex returns same response as GET#140626
Conversation
|
|
||
| final Map<String, Object> response = cancelReindexInProjectAndWaitForCompletion(taskId, projectWithReindex); | ||
| assertThat("reindex is cancelled", response, equalTo(Map.of("acknowledged", true))); | ||
| assertThat("reindex is cancelled", response, allOf(hasEntry("cancelled", true), hasEntry("completed", true))); |
There was a problem hiding this comment.
incoming yaml rest tests (next PR) will assert response more definitively
for now, just asserting the basics that are relevant for these tests
| 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)) |
There was a problem hiding this comment.
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:
cancelledfield is not recorded in tasks index, so a GET after cancellation seems to default to default value (false)POST _tasks/:taskId/_cancel?wait_for_completion=true&filter_path=nodes.*.tasks- Note the
cancelled: trueand absence of response/full-featured response{ "nodes": { "1RCnK_OnSamzfgmhcshBrA": { "tasks": { "1RCnK_OnSamzfgmhcshBrA:7281": { "node": "1RCnK_OnSamzfgmhcshBrA", "id": 7281, "type": "transport", "action": "indices:data/write/reindex", "start_time_in_millis": 1768412466161, "running_time_in_nanos": 6862322167, "cancellable": true, "cancelled": true, "headers": {} } } } } }
- Note the
GET _tasks/:taskId- Returns fully-featured response (task, slices, response, response.failures) and notably
cancelled: false
- Returns fully-featured response (task, slices, response, response.failures) and notably
in terms of what we're doing here, I see two main choices to get what we want (a more fully-featured response on POST _reindex/{task_id}/_cancel?wait_for_completion=true)
- what i currently have here: we generate the taskInfo here
- pros:
cancelled: true(makes sense)- slightly simpler code
- still get
status.slicesinformation, same asGET _reindex/{task_id}
- cons
running_time_in_nanosis calculated right hereSystem.nanoTime() - start, so this will be slightly different from what we will see inGET _reindex/{task_id}(taskInfo generated elsewhere)- don't get
response,response.failuresobjects
- pros:
- do a
GET _reindex/{task_id}transport call- pros:
- get exact same response as
GET _reindex/{task_id}, includingresponse - building on top of GET
- get exact same response as
- cons:
cancelled: false, confusing
- pros:
other potential avenues:
- we could get the full response using GET, and hackily flip cancelled to true
- i could investigate further whether any way to get from cancelTaskAndDescendants the full TaskResult that will be stored in tasks index, but assuming async stuff will make it hard to hand off
stating preference:
- i'm leaning towards saying what i have here is good enough, on first glance
responsefield returned in GET doesn't seem to have extra useful info other than what is here already within slices, mayberesponse.failuresfrom the BulkByScroll - in the unlikely case this is wanted, you can just do a folllow-up GET
- in previous conversations we didn't seem too bothered about having
responsebut we included it (from what i read, becausewhy not)
attaching below two files so reviewers can diff what is returned in POST _reindex/{task_id}/_cancel?wait_for_completion=true, and GET _reindex/{task_id} after cancellation
There was a problem hiding this comment.
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 cancelled is probably a good thing. The only thing that's giving me pause is that we're not consistent with get tasks... but there's no real reason we should be, since we're trying to mostly obfuscate the fact that this is wrappers around tasks (and esp. since that is doing something confusing around the cancelled field.)
|
Pinging @elastic/es-distributed-indexing (Team:Distributed Indexing) |
PeteGillinElastic
left a comment
There was a problem hiding this comment.
I think this LGTM, although I'd also be interested to see if @samxbr agrees.
| 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)) |
There was a problem hiding this comment.
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 cancelled is probably a good thing. The only thing that's giving me pause is that we're not consistent with get tasks... but there's no real reason we should be, since we're trying to mostly obfuscate the fact that this is wrappers around tasks (and esp. since that is doing something confusing around the cancelled field.)
PeteGillinElastic
left a comment
There was a problem hiding this comment.
I think I'm okay with this (see below) but I'd also be interested to know what @samxbr thinks.
POST _reindex/{task_id}/_cancel?wait_for_completion=true, similar to what is returned inGET _reindex/{task_id}since it's handy to have without doing a follow-up GET?wait_for_completion=falsereturns the existingacknowledge: trueresponseCloses elastic/elasticsearch-team#2086