I'm not sure that there is a logic bug in Juju, but we should understand what is going on in the system that is causing us to not refresh leadership correctly. I think the discussion around leader-elected is still relevant.
I'm not sure how much leader-disposed would actually help in this particular case. If you're in the middle of a hook, and you've ever called is_leader should we kill the execution of that script if we want to depose you?
It might work for some of the other cases where you need to tear things down that only got partially set up. Units still get a leader-settings-changed when the get demoted, so they could do the same work in that hook.
I'm not sure that there is a logic bug in Juju, but we should understand what is going on in the system that is causing us to not refresh leadership correctly. I think the discussion around leader-elected is still relevant.
I'm not sure how much leader-disposed would actually help in this particular case. If you're in the middle of a hook, and you've ever called is_leader should we kill the execution of that script if we want to depose you? settings- changed when the get demoted, so they could do the same work in that hook.
It might work for some of the other cases where you need to tear things down that only got partially set up. Units still get a leader-