Is it possible to have multiple tasks in a single Job where some of the groups are dependent on others and need to be completed first. It’s a chain of at least 3 links. I wasn’t sure if init has an order sequence or if it’s just binary.
I had a follow-up questions. Does the Lifecycle stanza work on groups too?
for example; if I have multiple groups is there a way that I wait for all groups to finish before running the final group?
No, lifecycle can only be defined for tasks. And even for tasks they revolved around the idea of main tasks and support tasks, meaning that they are made for building deep dependency graphs for example.
If you need finer-grain coordination between tasks and groups you will need to control it externally.
Depending on how complex is your use case, I think you could use template blocks and Consul KV store to block and unblock tasks. You would have a prestart task that checks for a Consul key. This will block the main task until the key is set. And then a poststop tasks that updates the key in Consul to unblock the next group.
You could probably use templating as well to build a job file that suits your need. Here’s an experiment as a example: Hacking Nomad Job Dependencies
Thanks. I’ll take a look; My use cases is interesting I suppose.
I have 5 tasks that all require 1 task to run first. Once the 1 task is done; the 4 tasks can run in parallel. I would prefer to use different computers (clients) since 1 of the 4 tasks requires a GPU the other do not…
using the trick of waiting for the service to show up in Consul also works (dig ...) as explained in one of the learn guides.
Q: @lgfa29 Consul Template can block for missing keys only, correct? can there be a CT expression to say “block until value fetched == X” ? ( the reason I ask is, unless using distinct keys for each run, subsequent runs will not “wait” as expected, correct?)
This is great, this should be put in the learn guides. (I would use the command as a template output which has the date command in it, to show which group/task ran before and after), but this is good stuff!