Set data on peer relation


Wondering if there is a recommended way to facilitate the sharing of information between units of an application via the peer relation?

Juju Show #39 - Beedy show and tell and news!

Is there something specific that you are looking for, other than just having them set data on the peer relation and have other peers read that information?

What kind of information are you looking to share?

I think many of the old cases for Peer relations actually end up better by using Leadership and having the leader set data for all the other units to read. Mostly because that ends up being a 1-N conversation instead of an N-N where they are all trying to figure out what bit of data to trust.


Agree with @jameinel. You can create an interface layer using Endpoints that contains only a file and do anything you normally can with a provides / requires interface, except that you would only have a single API for both sides of course, but it is almost always better to just have the leader make any decisions on behalf of the peers and setting it via leadership data. In addition to the scaling issue that @jameinel mentioned, relation data on the peer relation is transient while leadership data is persistent, meaning that if you lose and gain peer units, the leadership data will remain constant, whereas the relation data published by each peer unit will go away with the unit.

One case where you will need to use peer relation data, however, is if the peers need to inform the leader about some aspect of themselves. The most common case for this would be their network info (ingress / address), or just of their existence for the purposes of registering them, but you may even be able to get around this using the new goal-state feature (I haven’t looked into whether that’s feasible or not).

For peer relation interface layers, if you do end up using them, it’s probably better to just embed them directly in the charm (they currently need to be in hooks/relations/<endpoint-name>/ but I’d like to change that so they could also live under reactive/ somewhere), since they will never be used by any other layer.


@cory_fu @jameinel thanks for your responses. I was trying to have each unit of an application coordinate info to the leader, but I think I figured it out a different way (similar to what you have suggested).