Event 'leader-settings-changed'

Event > List of events > Lifecycle events > leader-settings-changed

Source: ops.LeaderSettingsChanged
See also: Leadership hook tools

The leader-settings-changed event is emitted when a leadership change occurs, all units that are not the new leader will receive the event. Also, this event is emitted if changes have been made to leader settings.


Emission sequence

During startup sequence, for all non-leader units:

Scenario Example Command Resulting Events
Create unit juju deploy foo -n 2 install -> leader-settings-changed -> config-changed -> start (non-leader)

If the leader unit is rescheduled, or removed entirely. When the new leader is elected:

Scenario Example Command Resulting Events
Removal of leader juju remove-unit foo/0 (foo/0 being leader) leader-settings-changed (for all non leaders)

Since this event needs leadership changes to trigger, check out triggers for leader-elected as the same situations apply for leader-settings-changed.

Observing this event in Ops

In Ops, you can observe the event like you would any other:


With Ops, you can test for leadership with self.unit.is_leader() (ops.Unit.is_leader).

When writing unit tests with the OF harness, leadership is set with self.harness.set_leader(True) (ops.testing.Harness.set_leader).

Behind the scenes, OF uses the hook-tools is-leader, leader-set and leader-get to interact with juju regarding leadership.

Last updated 5 months ago. Help improve this document in the forum.