-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Pre/Post hooks for tasks #1061
Comments
@sheerun We are thinking to introduce pre and post life cycle hooks in tasks so that would address your requirement. Currently, you will have to wrap your executable in a script and do the things you would like to do in that before the actual process starts. |
Converting the title to be about Pre/Post hooks |
An even better thing would be pluggable driver in form of script / binary that execs given command in specified environment. |
Just to add a use case. I like to notify slack when my service starts and stops. I can do this by running a scripts, so I am not proposing integrating with slack (maybe if there was a way to just kick off a periodic task on start and stop of a task?) |
Hi. Any updates on those two features? I could see both being very useful for security and monitoring systems. |
Also looking for an update. This would be extremely useful for us. |
Hey folks, this is definitely on the roadmap! The ticket will be updated when the feature lands |
Will it be pre/post hook both for running/stopping task? (to clean some /tmp stuff for example) mainly with exec drivers |
Yeah exactly, pre-start, post-start, pre-stop, post-stop |
Also (maybe I am a bit greedy...) could a hook point to an other job? If it can be recursive it could enable a kind of simple and self managed dependency system. |
Haha that is getting greedy 😛 You could accomplish that with a pre-start that uses Nomads API or wait for first class DAG support which is also on the roadmap |
@dadgar Yeah i was thinking about that kind of workaround ^^ Thanks for the quick replies :) |
I am looking forward to this feature. When do you plan to release? |
@kurochan This work has not been started yet so no release date to give you! |
Is #2767 a viable route to go? If the maintainers can comment on it - I could help @pondohva to get this in shape. Although I believe this should have a different interface. Something more like this:
|
@dreh23 separate pre/post interface looks good. |
Would these commands be executed inside or outside of the task's container ? I would love to be able to specify a full task config (driver etc.) for these hooks |
rkt (or at least the now-deprecated ACI spec) does have support for lifecycle hooks along these lines. I think this concept makes a lot of sense for the raw_exec driver, but I'm having a hard time envisioning how it would work in the general sense in the context of rkt or Docker containers. Performing tasks on the host when using the rkt driver would make for some trippy isolation cases. |
I think we need to run commands inside container, there are cases where we need to run DB migrations (e.g. django applications), or deregister from cluster/monitoring via post-hook |
Within a TaskGroup, there is no explicit ordering (other than the new |
To clarify our use case: |
I could see deployment hooks being very useful as well. In our old ansible-based deployment model, we had (ansible) tasks that reported the deployment to our chat and metrics systems. |
ContainerPilot has an interesting take on task ordering, based on lifecycle events. https://github.com/joyent/containerpilot/blob/master/docs/10-lifecycle.md#how-can-jobs-be-ordered |
Any update on this feature request? Or the custom driver feature? |
Also would be happy to see this live. Got very simple and important use case - flush cassandra database before shutdown. |
bump |
Another use case where this would be useful:
|
I stumbled upon this while looking for an option to manage Vault PKI issued certificates into a Java Keystore. For my usecase though a pre-start hook isn't good enough as this wouldn't handle the credential changing. For this usecase a "post-template" hook would be ideal (executes after the template file is rendered to disk, but before the task is started or change_mode action is performed). |
I am using the same but now how does nomad monitor each docker started with compose ?. How are you managing restarting the same ?. |
I think it's worth relating this issue with #419, as the implementation we are considering at the moment is indeed via pre/post hooks to enable running tasks in a predefined sequential order. |
Will it be possible to mix types? Like have a batch task and a service task
together? It always feels a bit nasty running a service task to run a 1-off
script and artificially keeping it around with tail -f /dev/null so the
whole job doesnt get killed.
Greetings,
Erik
…On Fri, Oct 25, 2019, 01:55 Yishan Lin ***@***.***> wrote:
I think it's worth relating this issue with #419
<#419>, as the implementation we
are considering at the moment is indeed via pre/post hooks to enable
running tasks in a predefined sequential order.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1061?email_source=notifications&email_token=AAFLNGKEHCMNXMAC54KVSMDQQIYXJA5CNFSM4CANLMBKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECGYOOI#issuecomment-546146105>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFLNGJJ67KK4TYRUNCQP3DQQIYXJANCNFSM4CANLMBA>
.
|
I faced the similar issue in our deployments, so I created a tool. |
Shipped in 0.11.0-beta1 |
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
Hey,
I'd like to setup environment for a task before running it (for example mount an nfs volume). I'm using raw exec task driver. What is the best to do so with nomad?
Basically I need a way to run tasks in sequence instead in parallel.
Adam
The text was updated successfully, but these errors were encountered: