Add Hooks / Signals #687
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I propose to add hooks (and signals?) to the installation / upgrade procedure, so that recipes can communicate while they're installed, upgraded, and removed. The first use-case is to improve handling non-standard setups with traefik, like also discussed in #686. But I think a lot of other use-cases can be solved.
One thing I'm not sure is whether it should be hooks, or a more generic signalling system - here is my understanding of the difference (feel free to add your definition :)
As a first step, we could define some default signals for the system:
For the hooks, this can be something like the following, to give the recipes more possibilities to interact during their lifecycle. There are default things happening in the hooks, which can be overwritten with a shell script of the name of the hook.
Recipes can then:
This would allow to have whatever TLS termination tool somebody likes, or have more complex setups (I run my co-op server in a VM, which is behind the TLS terminating traefik).
Thanks for opening @ineiti 👏 This issue here is heavily related: #682 /cc @notplants
I think I understand this proposal, which I fully support and would like to make progress. We have some technical limitations based on our previous choices. Namely, we have currently been taken hostage by how Docker Swarm works.
abradoes what the Docker CLI does, it merges thecompose.*ymlfrom the recipe config and deploys them as a bunch of services which has a shared namespace (Docker Stack). "The recipe" then becomes "An App" in our terminology.So,
This means actually that the services/stack emits signals from the docker runtime. There is an API for this: https://docs.docker.com/reference/cli/docker/system/events/ However, it's quite a confusing API because, again, the way Docker Swarm works with rolling updates. It's hard to get insights into if a deployment succeeded, failed, was rolled back, etc. (explained more in #682)
I believe this would require some API interaction between
abraand whatever$proxyyou are using. This then comes back to #686 and the question if we want to support multiple or a single proxy. A single proxy support (for me, ideally Caddy), then we could ask Caddy if the deployment is doing specific things from a traffic perspective.A concrete example of this is how uncloud.run (a similar project) manages their proxy: https://uncloud.run/docs/concepts/ingress/managing-caddy
I think you could figure out these moments but it would require introspecting the Docker system events API and trying to pull out an event which matches this moment. I have struggled to figure this out but hopefully someone who is better at programming could do this! The current implementation of
abra app deploydoes some watching of the state, it could be a good entrypoint for other Go hackers: https://git.coopcloud.tech/toolshed/abra/src/branch/main/pkg/ui/deploy.go Lining up scripts to run at these moments was also discussed in #682.To conclude, I hope this is useful! It's one of the major issues we're running up against and we all do want solutions. It's just a question of how, which doesn't break peoples deployments and maintains backwards compatibility. I sadly have little time to investigate this because
$lifeatm but I can support. Anything you want to experiment with, prototype, propose, show & tell, is welcome!Hmm - so you would have to translate the docker-
labelsin a way that they can be passed toabra.sh? So you could: call allabra.shfrom all other services on this server with a pre-defined command, e.g.,label([[key0, value0], [key1, value1]]), even though that's a bit clumsy with bash...And it would need some additional information like the server, service-name, or such. Even though this could also be put in the labels.
For the different services, you would have to define default labels, for example:
abra.proxy.server.service.urlto register anurlto theserviceon theserverAll labels starting with
abraare defined by co-op cloud, other labels can be defined by the community.