Commit a3b110e
authored
Add collect-status events for multi-status handling (canonical#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.1 parent dd4865f commit a3b110e
File tree
9 files changed
+400
-23
lines changed- ops
- test
9 files changed
+400
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
| 190 | + | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
826 | 830 | | |
827 | 831 | | |
828 | 832 | | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
829 | 910 | | |
830 | 911 | | |
831 | 912 | | |
| |||
882 | 963 | | |
883 | 964 | | |
884 | 965 | | |
885 | | - | |
| 966 | + | |
| 967 | + | |
886 | 968 | | |
887 | 969 | | |
888 | 970 | | |
889 | 971 | | |
890 | 972 | | |
891 | 973 | | |
892 | | - | |
| 974 | + | |
| 975 | + | |
893 | 976 | | |
894 | 977 | | |
895 | 978 | | |
896 | | - | |
| 979 | + | |
| 980 | + | |
897 | 981 | | |
898 | 982 | | |
899 | 983 | | |
900 | | - | |
| 984 | + | |
| 985 | + | |
901 | 986 | | |
902 | 987 | | |
903 | 988 | | |
904 | | - | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
905 | 1001 | | |
906 | 1002 | | |
907 | 1003 | | |
| |||
995 | 1091 | | |
996 | 1092 | | |
997 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
998 | 1111 | | |
999 | 1112 | | |
1000 | 1113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
443 | 445 | | |
444 | 446 | | |
445 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
322 | 323 | | |
323 | 324 | | |
324 | 325 | | |
| |||
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
334 | 339 | | |
335 | 340 | | |
336 | 341 | | |
| |||
465 | 470 | | |
466 | 471 | | |
467 | 472 | | |
| 473 | + | |
468 | 474 | | |
469 | 475 | | |
470 | 476 | | |
| |||
479 | 485 | | |
480 | 486 | | |
481 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
482 | 492 | | |
483 | 493 | | |
484 | 494 | | |
| |||
1583 | 1593 | | |
1584 | 1594 | | |
1585 | 1595 | | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1586 | 1613 | | |
1587 | 1614 | | |
1588 | 1615 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1484 | 1484 | | |
1485 | 1485 | | |
1486 | 1486 | | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
1487 | 1502 | | |
1488 | 1503 | | |
1489 | 1504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
0 commit comments