RestartTask endpoint
https://redmine.teklia.com/issues/6515
People want to restart tasks a lot, but restarting a task is a hack that currently erases the logs of the previous task execution without erasing the artifacts, which causes a lot of confusion when troubleshooting processes. We can make this make more sense by cloning the task instead, leaving the already finished task alone.
An entirely separate RestartTask
endpoint must be created, as a CreateAPIView
on /api/v1/task/<id>/restart/
:
- When the task's process is not readable by the user, it should return HTTP 404.
- When the task's process is readable, but the user does not have admin acccess, it returns HTTP 400.
- When the task is not in a final state, it should also return an HTTP 400.
- Otherwise:
- It creates a new task with the same attributes as the existing task.
- The new task's slug has a
_{number}
suffix, starting at 2, to imply this is the second time the task runs. - The new task is in a
pending
state. - All tasks that depended on the old task now depend on the new task.
This means that starting with this graph:
graph LR
init_elements --> my_worker
my_worker --> other_worker
After restarting my_worker
, the graph now looks like this:
graph LR
init_elements --> my_worker
init_elements --> my_worker_2
my_worker_2 --> other_worker
Supporting a restart with RQ is a follow-up, in #1696 (closed).