Comment 7 for bug 1728111

Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

I think the only way to really control for this error, is wrap every call to leader_set(...) in a try: ... except: as the leadership can change during hook execution. i.e. even if is_leader() -> True, it's still possible for a later leader_set(...) set to fail. It's better to catch that failure, and undo any 'leader' things the hook was doing, and then exit the hook, and the new leader unit to perform the leadership actions instead.

e.g. Unless Juju can provide a guarantee that leadership won't change during a hook execution, then charms are going to have to back out of a leader_set(...) failure gracefully.