Closed balbirthomas closed 1 year ago
Hello @balbirthomas! Is this really an enhancement for the Operator Framework, or a feature idea for Juju itself?
I think what you're calling 'Level Events' are what we've called 'dependencies' in #329.
@chipaca It's not exactly the same. The Dependency
proposal is more about collecting a group of conditions together with a cleaner UX where the individual conditions (at least all the ones listed in that example) are notified by existing Juju-triggered hooks. Whereas the custom application-level events proposed here seem to be more about having charm code called based on external triggers which are not modeled by Juju.
I think something like this has been discussed here and there in the past with the main limitation being the need for a hook context. The closest approximation I think we have today is having the charm start a background service which watches for the condition and calls the juju-run
hook tool, which can be used to trigger a custom event by faking the JUJU_DISPATCH_PATH
environment variable. Obviously, that's pretty hacky and I'm not sure if that approach would work on a Kubernetes charm, though. A cleaner solution would definitely require some additional support from Juju itself.
Part of this is a Juju bug -- which will be handled with the upcoming Pebble Notices (aka Pebble Events) feature.
From the OF side, you can run ./dispatch with the JUJU_DISPATCH_PATH
env var set to "hooks/custom_name" and it will execute the event.
Use Case
The operator framework and Juju provide a useful set of application lifecycle events that charms use in managing their application states. These pre-defined events satisfy most of the use cases. However there are instances when there is a need to create custom events and triggers for these events. Consider a few examples to illustrate this
Custom Events and Triggers
Use cases such as those listed above can be handled by charms if the following two features were available