|
| 1 | +# RFC 0190 - Queue change task run priority |
| 2 | +* Comments: [#0190](https://github.com/taskcluster/taskcluster-rfcs/pull/190) |
| 3 | +* Proposed by: @lotas |
| 4 | + |
| 5 | +## Summary |
| 6 | + |
| 7 | +Since we refactored queue internals it became possible to see what tasks are pending for a particular |
| 8 | +worker pool / task queue. |
| 9 | + |
| 10 | +This RFC proposes new API method that would allow to change the priority of the existing task run. |
| 11 | + |
| 12 | +## Motivation |
| 13 | + |
| 14 | +There might be several use-cases when some worker pool has a lot of pending tasks and there is a need |
| 15 | +to move some more important task to the top of the waiting list, or also move down less important ones. |
| 16 | + |
| 17 | +Instead of cancelling existing tasks we can instead choose to change task run priorities. |
| 18 | + |
| 19 | +## Details |
| 20 | + |
| 21 | +I propose we implement this on a task run level and not the task itself: |
| 22 | + |
| 23 | +* tasks are supposed to be immutable |
| 24 | +* changing the priority makes more sense in the context of a specific run, not the whole task |
| 25 | + |
| 26 | +Queue service will expose new method `queue.changeTaskRunPriority(taskId, runId, newPriority)`. |
| 27 | + |
| 28 | +This will try to do the following: |
| 29 | + |
| 30 | +* update `task.runs[runId]` in the database to reflect priority change (possibly extra field to keep the original) |
| 31 | +* update `priority` field in the `queue_pending_tasks` table |
| 32 | + |
| 33 | +If any of this fails (for example task is being changed by some other process), this method will also fail. |
| 34 | + |
| 35 | +This will also require introduction of the new scopes (anyOf): |
| 36 | + |
| 37 | +* `queue:change-task-run-priority-in-queue:<taskQueueId>` |
| 38 | +* `queue:change-task-run-priority:<taskId>` |
| 39 | + |
| 40 | + |
| 41 | +Current order for picking up tasks is based on the task priority and insertion time (FIFO). |
| 42 | +This RFC proposes to change the priority only, and leave the insertion time as is. |
| 43 | + |
| 44 | + |
| 45 | +### Other considerations |
| 46 | + |
| 47 | +Chain of Trust validation might be broken if we change too much of the task definition or run. |
| 48 | +We need to make sure we don't break it with this change. |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +## Implementation |
| 54 | + |
| 55 | +_pending_ |
0 commit comments