Juju state machine documentation and visualization

Hi Erik,

The <relation-name>-relation-created hook family was added in Juju 2.8 to address some stateful application initialization uses-cases. I think the event lifecycle docs haven’t been updated yet (ping @juju-developers).

relation-created is particularly useful in a scenario where you want to use application relation data (introduced in 2.7.0) on a peer relation which is supposed to replace leader data - bug Bug #1859769 “[2.7.1] peer relation (and its app relation data) ...” : Bugs : Canonical Juju has some particularities as to why that was introduced.

Operator Framework does not even expose leader data and expects that developers use app relation data with peer relations.

I think the diagram is quite useful for understanding main loop-like semantics of how units operate. Looking at it now, I think it could be enhanced by adding some information about sources of events and the context available in them.

Event objects in the framework do a better job at exposing the context than what was available before: https://ops.readthedocs.io/en/latest/index.html#ops.charm.RelationCreatedEvent https://ops.readthedocs.io/en/latest/index.html#ops.charm.ActionEvent

1 Like