leader-settings-changed firing before unit departure
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
High
|
Ian Booth |
Bug Description
Hi team. I had some weird behavior for this set up / situation
For Example. If you have these units:
```
A *
B
C
```
and `A` departs then you get these events hooks for each unit:
`A`: `leader-
`B`: `mongodb-
`C`: `mongodb-
According to @wallyworld and @rwcarlsen this is unexpected behaviour and should be looked into. As requested, [this](https:/
```
# pack and deploy
charmcraft pack
juju deploy -n3 ./*charm
# in a separate session
juju debug-hooks <leader_unit>
# remove unit
juju remove-unit <leader_unit
```
Changed in juju: | |
milestone: | 2.9.27 → 2.9.28 |
Changed in juju: | |
status: | In Progress → Fix Committed |
Changed in juju: | |
status: | Fix Committed → Fix Released |
Looking at the intent of the code, the unit agent has this logic:
// We want to run the leader settings hook if we're LeaderSettingsV ersion != remoteState. LeaderSettingsV ersion { NewRunHook( hook.Info{ Kind: hooks.LeaderSet tingsChanged} )
// not the leader and the settings have changed.
if !localState.Leader && localState.
return opFactory.
}
So we should only run leader- settings- changed if the unit is not the leader. Unit A was the leader at the time it was removed - and we are supposed to only take away leadership when unit A goes to Dead, ie after all hooks have been run. So it does seem something is amiss here.