-
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
Task Lifecycle PostStop Hook #8193
Comments
answering questions from #8194 (review)
PostStop run after all main tasks dead, regardless of what caused the main tasks to die (complete, kill or failure). If we want differentiation in behavior, we could introduce a PostFail case.
PostStop should run if
Yes, that makes the most sense to me.
More questions
TODO:
|
sample use cases
poststop cannot be sidecars
|
MVPThe Cleanup use case Right before allocation is going to die (i.e. all the main tasks have stopped & are not being restarted anymore) => Do some stuff
|
Rebasing ShenanigansI broke nomad client shutdownI have been rebasing this branch off of the It appears to get caught just after garbage collectionwhile waitingfor allocrunners to be destroyed (destroy themselves?).(Note: it is
|
|
TODOtechnical work
design work
|
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. |
Design
Poststop is intended to be a cleanup hook: i.e. after main tasks have become terminal.
Poststop tasks run every time:
If the poststop task fails, the allocation is restarted (along with all non-poststop tasks) and typical allocation failure logic applies. The idea is that poststop tasks can gives users the ability to catch and hande errors internally within an allocation. For some use cases (eg Artifact upload below), the poststop hook is a critical part of the overall allocation.
Potential Future Features:
Use Case: Cleanup
A service job writes files to a host volume that should be cleaned up on shutdown. The poststop task removes these files.
Since cleanup is a best effort, the cleanup script itself silently ignores errors to prevent causing the allocation to be failed if cleanup fails.
Use Case: Artifact upload
A batch job that runs Packer to build a local VM image needs to upload that image to remote storage after building.
While in this use case the poststop uploader does not need to run if Packer fails, it's fine if it attempts to anyway as it will just fail to find the local VM image to upload.
Use Case: Event Signalling / Task Group Dependencies
Use a PostStop task to signal some external service via API request etc
Implementation
you can fail poststop tasks if they stallThe text was updated successfully, but these errors were encountered: