Skip to content
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

Fix cancel tasks API #3036

Merged
merged 3 commits into from
May 4, 2024
Merged

Conversation

joelvim
Copy link
Contributor

@joelvim joelvim commented Apr 5, 2024

Elasticsearch provides two ways to cancel a task

  • by its id : POST _tasks/oTUltX4IQMOUUVeiohTt8A:12345/_cancel
  • by node & actions : POST _tasks/_cancel?nodes=nodeId1,nodeId2&actions=*reindex

Elastic4s which takes nodeIds and actions, provides a single interface for both, but both are broken :

  • if no node id is provided, the endpoint returned is s"/_tasks/cancel" while it should be s"/_tasks/_cancel"
  • if node ids are provided, it returns s"/_tasks/task_id:${request.nodeIds.mkString(",")}/_cancel" but this URL is invalid for two reasons:
    • task_id in the path breaks the task id that is provided,
    • the API does not support more than one task.
      Both result in a 400 with "reason": "malformed task id task_id:<my_task_id>"

As the handler always returns a Right override def handle(response: HttpResponse) = Right(response.statusCode >= 200 && response.statusCode < 300) this API always fail silently.

My solution is to provide a new API cancelTaskById(taskId: String) to prevent ambiguities from the use of the other API that becomes a pure nodeIds + actions API.

@Philippus Philippus merged commit 803b0c3 into Philippus:master May 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants