Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for sequential job definitions #854

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

njakobsen
Copy link

@njakobsen njakobsen commented Jul 31, 2024

Jobs now support a sequence option that will cause jobs with the same sequence value to run sequentially when scheduled for the same time. sequential: true can be passed to the every block to automatically set a common sequence value for each contained job.

every 3.hours, sequential: true do
  # Jobs in this block that don't set their own sequence will default to run in the same sequence (not in parallel)
  runner "MyModel.some_process", halt_sequence_on_failure: true # If this job fails, subsequent jobs will not run (defaults to false)
  rake "my:rake:task"
  command "/usr/bin/my_great_command", sequence: nil # This job runs in parallel with other jobs that are not part of a sequence
  runner "MyModel.task_to_run_at_four_thirty_in_the_morning", sequence: 'other' # This job runs sequentially with other jobs in the sequence called 'other'
end

Outstanding Questions

  • Is there a need to configure the command delimiter? i.e. is && always what we want, or do we want to be able to use ; so the sequence continues even if one command fails. This feature has been added.

Note

  • This PR also includes a previous PR of mine that allows the options set on an every block to be overridden by those set on the individual jobs in the block.

Local options override globally set options, but options set on the `every` group do not.

It makes sense for the options defined closer to the actual job to override those set further away, so we change the merge order of options to allow options passed to `every` to override those set globally with `set`. We still allow local options set on each job to override those set on the group.
Jobs now support a `sequence` option that will cause jobs with the same `sequence` value to run sequentially when scheduled for the same time. `sequential: true` can be passed to the `every` block to automatically set a common `sequence` value for each contained job.

Closes javan#19
Closes javan#696
Closes javan#835
It's likely that since jobs ran in parallel before, there were no dependencies between jobs. Therefore, now that sequential jobs are possible, we should continue execution of the job sequence even if one job fails. To override this and halt the sequence on failure, individual jobs can set `halt_sequence_on_failure: true` to suffix their command with an "&&" instead of a ";".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant