Skip to main content

Routines run once when due, on behalf of whoever set them up

Recurring work, such as a weekly cluster health check, needed someone to remember to create the task. We decided that an organization can have routines: a five-field cron schedule, read in an IANA timezone, and the task it creates each time it is due. The task is an ordinary task, so the agent it is assigned to starts on it like any other. A routine keeps when it is next due in the database and the server looks every 30 seconds for routines that are due.

Considered Options​

  • Catch up every run missed while the server was down: rejected; a server down over a long weekend would wake to a pile of identical tasks. A routine that was due runs once, marked late.
  • Always create the task, open or not: rejected as the default; an unfinished health check is better followed than doubled. A routine skips a run while its previous task is still open, unless it is told not to, and says so in its run log.
  • Routine tasks created by Mission Control (no creator): rejected; a task's creator and requester tell its agent whom it works for (ADR 0008). Its tasks are created by whoever set the routine up, a person or a role, and point back at the routine.

Consequences​

  • Managing routines takes routines.manage; owners hold it, and roles can be granted it like any permission, so a role such as Head of IT can set up another role's recurring work.
  • A routine's task title and description are templates with their own small context (the routine, the day it was due, its ISO week, and its previous task), checked when saved.
  • Every run is logged: the task it created, or why it skipped or failed (a removed project, an assignee who left). A failure never stops the schedule.
  • A change to the schedule, the timezone or turning it on counts from now; "Run now" runs it outside its schedule and leaves when it is next due as it was.