The lifecycle Block - Job Specification | Nomad | HashiCorp Developer shows an example of cleanup task pattern. It is not very useful.
It just sends a message that “All done!”. That might be not true. In case job failed, nothing was done. The message should get the status of the allocations, why they failed, and send a success of failure message.
How to check that? It is expected to do Nomad API requests from within the poststop task to get the status? Is there a NOMAD_TOKEN automatically exported inside poststop task or something else that might be usefull to do that?