Open jpbruinsslot opened 1 year ago
Can I add a request to this? When you have 10 failed tasks, it would be nice to select all the failed tasks and then simply hit the reschedule button instead of having to manually select all of them for rescheduling.
The design has been agreed upon, with the advice to make sure that database normalization would be possible in the future
Context
The scheduler now references the
/random
endpoint from octopoes to get ooi's for rescheduling of tasks (ooi * available boefjes = tasks). To keep track of recurring tasks within the scheduler we allow for:Proposed solution
Changes
Change 1:
Schedule
modelCreate a new model
Schedule
which contains the necessary information to create a newTask
. ASchedule
has a 1-to-many relationship with an instancedTask
. The updated entity relationship diagram for the scheduler:With both models looking like follows:
https://github.com/minvws/nl-kat-coordination/blob/394202903d434cbb9f950a89b403421feb44ed63/mula/scheduler/models/schema.py#L22-L41
https://github.com/minvws/nl-kat-coordination/blob/394202903d434cbb9f950a89b403421feb44ed63/mula/scheduler/models/task.py#L47-L66
The
data
field contains the actual data that is needed for a task runner to execute its task, in case of aBoefjeScheduler
this is aBoefjeTask
:Change 2: Removal of the
PrioritizedItem
table and modelRemoval of the
PrioritizedItem
model and table. By removing this, a substantial decrease in data duplication within the scheduler has been achieved. The queue is now 'materialized' by filtering on the task table based on the status of aTask
, i.e. all task with the statusQUEUED
. In practice this means the following, when a task is created (either by manual entry, enabling of boefjes, rescheduling, etc) this task is added to the task table, and for every task that gets created aSchedule
is created as well.Example of both
Task
andSchedule
table, here aSchedule
already scheduled aTask
in the past, andQUEUED
aTask
in the future.Schedule table:
{}
0 12 * * 1
Task table:
{}
{}
When a task with the highest priority needs to be removed from the queue the following code is then being executed:
https://github.com/minvws/nl-kat-coordination/blob/394202903d434cbb9f950a89b403421feb44ed63/mula/scheduler/storage/pq_store.py#L16-L34
The rescheduling of tasks can be imagined as follows: the
BoefjeScheduler
queries theSchedule
table where the deadline has passed (meaning a task needs to be scheduled now, and pushed onto the queue). ATask
will be created and inserted into theTask
table. A Task Runner can then retrieve a task through the server API, run the task and update the status when it finished.Tasklist
test_scheduler.py
Pull Request
Associated issues