-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add collect-status events for multi-status handling (#954)
This implements the `collect_app_status` and `collect_unit_status` events that can be used by charms to allow the framework to automatically collect status (from multiple components of the charm) and set status at the end of every hook. API reference under [`CollectStatusEvent`] (https://ops--954.org.readthedocs.build/en/954/#ops.CollectStatusEvent), though I'll also add usage examples to the new "charm status" SDK doc that Dora is creating. Spec and examples described in [OP037] (https://docs.google.com/document/d/1uQNgif0GG03TdnqT4UM9BxEshXuSvCmT9TdxOHoIUkI/edit). The implementation is very straight-forward: `model.Application` and `model.Unit` each have a list of `_collected_statuses`, and `CollectStatusEvent.add_status` adds to the correct one of those. Then after every hook in `ops/main.py` we call `_evaluate_status`, which triggers each event and sets the app or unit status to the highest-priority status collected (if any statuses were collected). Note that `collect_app_status` is only done on the leader unit. To test when using `ops.testing.Harness`, use `Harness.evaluate_status`. This has full unit tests, including in `test_main.py`, but I've also confirms this works on a real production deploying on Juju.
- Loading branch information
Showing
9 changed files
with
400 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.