cron.rst (3671B)
1 Periodic Taskgraphs 2 =================== 3 4 The cron functionality allows in-tree scheduling of task graphs that run 5 periodically, instead of on a push. 6 7 Cron.yml 8 -------- 9 10 In the root of the Gecko directory, you will find `.cron.yml`. This defines 11 the periodic tasks ("cron jobs") run for Gecko. Each specifies a name, what to 12 do, and some parameters to determine when the cron job should occur. 13 14 See `the schema <https://github.com/mozilla-releng/fxci-config/blob/main/build-decision/src/build_decision/cron/schema.yml>`_ 15 for details on the format and meaning of this file. 16 17 How It Works 18 ------------ 19 20 The `TaskCluster Hooks Service <https://firefox-ci-tc.services.mozilla.com/hooks>`_ 21 has a hook configured for each repository supporting periodic task graphs. The 22 hook runs every 15 minutes, and the resulting task is referred to as a "cron task". 23 That cron task runs the `build-decision 24 <https://github.com/mozilla-releng/fxci-config/tree/main/build-decision>`_ image. 25 26 The task reads ``.cron.yml``, then consults the current time (actually the time 27 the cron task was created, rounded down to the nearest 15 minutes) and creates 28 tasks for any cron jobs scheduled at that time. 29 30 Each cron job in ``.cron.yml`` specifies a ``job.type``, corresponding to a 31 function responsible for creating TaskCluster tasks when the job runs. 32 33 Describing Time 34 --------------- 35 36 This cron implementation understands the following directives when 37 describing when to run: 38 39 * ``minute``: The minute in which to run, must be in 15 minute increments (see above) 40 * ``hour``: The hour of the day in which to run, in 24 hour time. 41 * ``day``: The day of the month as an integer, such as `1`, `16`. Be cautious above `28`, remember February. 42 * ``weekday``: The day of the week, `Monday`, `Tuesday`, etc. Full length ISO compliant words. 43 44 Setting both 'day' and 'weekday' will result in a cron job that won't run very often, 45 and so is undesirable. 46 47 *Examples* 48 49 .. code-block:: yaml 50 51 # Never 52 when: [] 53 54 # 4 AM and 4 PM, on the hour, every day. 55 when: 56 - {hour: 16, minute: 0} 57 - {hour: 4, minute: 0} 58 59 # The same as above, on a single line 60 when: [{hour: 16, minute: 0}, {hour: 4, minute: 0}] 61 62 # 4 AM on the second day of every month. 63 when: 64 - {day: 2, hour: 4, minute: 0} 65 66 # Mondays and Thursdays at 10 AM 67 when: 68 - {weekday: 'Monday', hour: 10, minute: 0} 69 - {weekday: 'Thursday', hour: 10, minute: 0} 70 71 .. note:: 72 73 Times are expressed in UTC (Coordinated Universal Time) 74 75 76 Decision Tasks 77 .............. 78 79 For ``job.type`` "decision-task", tasks are created based on 80 ``.taskcluster.yml`` just like the decision tasks that result from a push to a 81 repository. They run with a distinct ``taskGroupId``, and are free to create 82 additional tasks comprising a task graph. 83 84 Scopes 85 ------ 86 87 The cron task runs with the sum of all cron job scopes for the given repo. For 88 example, for the "sequoia" project, the scope would be 89 ``assume:repo:hg.mozilla.org/projects/sequoia:cron:*``. Each cron job creates 90 tasks with scopes for that particular job, by name. For example, the 91 ``check-frob`` cron job on that repo would run with 92 ``assume:repo:hg.mozilla.org/projects/sequoia:cron:check-frob``. 93 94 .. important:: 95 96 The individual cron scopes are a useful check to ensure that a job is not 97 accidentally doing something it should not, but cannot actually *prevent* a 98 job from using any of the scopes afforded to the cron task itself (the 99 ``..cron:*`` scope). This is simply because the cron task runs arbitrary 100 code from the repo, and that code can be easily modified to create tasks 101 with any scopes that it possesses.