broken/departed are not handled properly

Bug #1084263 reported by Clint Byrum
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
postgresql (Juju Charms Collection)
Fix Released
Undecided
Stuart Bishop

Bug Description

While reviewing this Merge Proposal:

https://code.launchpad.net/~cjwatson/charms/precise/postgresql/broken-departed-hooks/+merge/135132

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-ids/relation-list/relation-get.

Related branches

Stuart Bishop (stub)
Changed in postgresql (Juju Charms Collection):
status: New → In Progress
assignee: nobody → Stuart Bishop (stub)
Stuart Bishop (stub)
Changed in postgresql (Juju Charms Collection):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.