|
1 | | -# RFC 0190 - Queue change task run priority |
| 1 | +# RFC 0190 - Queue change task / task group priority |
2 | 2 | * Comments: [#0190](https://github.com/taskcluster/taskcluster-rfcs/pull/190) |
3 | 3 | * Proposed by: @lotas |
4 | 4 |
|
|
7 | 7 | Since we refactored queue internals it became possible to see what tasks are pending for a particular |
8 | 8 | worker pool / task queue. |
9 | 9 |
|
10 | | -This RFC proposes new API method that would allow to change the priority of the existing task run. |
| 10 | +This RFC proposes new API method that would allow to change the priority of the existing task run / task group. |
11 | 11 |
|
12 | 12 | ## Motivation |
13 | 13 |
|
14 | 14 | There might be several use-cases when some worker pool has a lot of pending tasks and there is a need |
15 | 15 | to move some more important tasks to the top of the waiting list, or also move down less important ones. |
16 | 16 |
|
17 | | -Instead of cancelling existing tasks we can instead choose to change task run priorities. |
| 17 | +Instead of cancelling some existing tasks we can change task run priorities. |
| 18 | + |
| 19 | +Use-case examples: |
| 20 | + |
| 21 | +* We have a high-priority patch running tasks on Try. We want to bump the priority of all tasks in this task group |
| 22 | +* We have a chemspill release or high priority nightly to get out. We want to bump the priority of all tasks in one or more groups |
| 23 | +* We are waiting for a specific task in a low resource pool (eg: mac hardware). We want to bump the priority of that specific task |
| 24 | +* There are several tasks with the same highest priority and one of them is more important. We want to lower the priority of the less important task |
18 | 25 |
|
19 | 26 | ## Details |
20 | 27 |
|
21 | | -I propose we implement this on a task run level and not the task itself: |
| 28 | +Queue service will expose new methods: |
| 29 | + |
| 30 | +* `queue.changeTaskPriority(taskId, newPriority)` |
| 31 | +* `queue.changeTaskGroupPriority(taskGroupId, newPriority)` |
| 32 | + |
| 33 | +New priority would be stored along the task definition for a given task or all tasks within the task group. |
22 | 34 |
|
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 |
| 35 | +The process to change single task will be as follows: |
25 | 36 |
|
26 | | -Queue service will expose new method `queue.changeTaskRunPriority(taskId, runId, newPriority)`. |
| 37 | +* new task priority will be stored in the database as `task.priority_override` column |
| 38 | +* if task was scheduled already, its priority in the `queue_pending_tasks` table will be updated |
| 39 | +* if the tasks run fails and new one is created, it will check if `task.priority_override` is set and use it instead of the original priority |
27 | 40 |
|
28 | | -This will try to do the following: |
| 41 | +The process to change the whole task group will be as follows: |
29 | 42 |
|
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 |
| 43 | +* all tasks in the task group will be updated to store the new priority in the `task.priority_override` column |
| 44 | +* all currently scheduled tasks would be attempted to be updated in the `queue_pending_tasks` table |
| 45 | +* all unscheduled tasks and tasks that will be restarted will use the new priority |
32 | 46 |
|
33 | | -If any of this fails (for example task is being changed by some other process), this method will also fail. |
| 47 | +### New scopes |
34 | 48 |
|
35 | 49 | This will also require introduction of the new scopes (anyOf): |
36 | 50 |
|
37 | | -* `queue:change-task-run-priority-in-queue:<taskQueueId>` |
38 | | -* `queue:change-task-run-priority:<taskId>` |
39 | | -* `queue:lower-task-run-priority:<taskId>` to only allow lowering the priority |
40 | | -* `queue:raise-task-run-priority:<taskId>` to only allow raising the priority |
| 51 | +* `queue:change-task-priority-in-queue:<taskQueueId>` |
| 52 | +* `queue:change-task-priority:<taskId>` |
| 53 | +* `queue:lower-task-priority:<taskId>` to only allow lowering the priority |
| 54 | +* `queue:raise-task-priority:<taskId>` to only allow raising the priority |
| 55 | + |
| 56 | +And for task group: |
| 57 | + |
| 58 | +* `queue:change-task-group-priority:<schedulerId>/<taskGroupId>` (for consistency with existing task group scopes) |
| 59 | +* `queue:lower-task-group-priority:<taskGroupId>` to only allow lowering the priority |
| 60 | +* `queue:raise-task-group-priority:<taskGroupId>` to only allow raising the priority |
| 61 | + |
| 62 | +### Priority calculation |
41 | 63 |
|
42 | 64 | Current order for picking up tasks is based on the task priority and insertion time (FIFO). |
43 | 65 | This RFC proposes to change the priority only, and leave the insertion time as is. |
44 | 66 |
|
45 | 67 | ### Other considerations |
46 | 68 |
|
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. |
| 69 | +To insure that Chain of Trust validation is not affected, we aim to keep the original task definition |
| 70 | +and store the new priority in a separate column. |
49 | 71 |
|
50 | 72 | ## Implementation |
51 | 73 |
|
|
0 commit comments