broken/departed are not handled properly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
postgresql (Juju Charms Collection) |
Fix Released
|
Undecided
|
Stuart Bishop |
Bug Description
While reviewing this Merge Proposal:
https:/
I noticed that the hooks.py script in the charm is badly in need of a refactor to handle departed/broken.
While the change above is suppressing the error, its definitely just a band-aid.
Departed happens when only one of the units of the related service is removed. broken happens when the entire relationship is removed.
In a departed hook, you have access to the unit that departed, and can remove just the resources that it was consuming (such as a GRANT or IP-specific access controls). With broken, you are obligated to tear all of these down, and can only do so using $JUJU_RELATION_ID, as relation-list will not function.
So when I read hooks.py, I see db-relation-broken being, no pun intended, badly broken, as it is doing a relation-get, which is really not possible at all. It does a bare try: except:, which is really bad form in any python program, but in this case is masking the fact that broken is most definitely failing every time.
A refactor around $JUJU_RELATION_ID is needed to make this charm reliable.. and it appears that basically on every relation hook, the whole config should just be regenerated using relation-
Related branches
- charmers: Pending requested
-
Diff: 144 lines (+45/-18)1 file modifiedhooks/hooks.py (+45/-18)
Changed in postgresql (Juju Charms Collection): | |
status: | New → In Progress |
assignee: | nobody → Stuart Bishop (stub) |
Changed in postgresql (Juju Charms Collection): | |
status: | In Progress → Fix Released |