[2.7.1] peer relation (and its app relation data) is not available at the time leader-elected is run for the first time

Bug #1859769 reported by Dmitrii Shcherbakov on 2020-01-15
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
juju
High
Achilleas Anagnostopoulos

Bug Description

Scenario: one unit, app relation data on a peer relation is used instead of leader data for peer initialization.

* install: relation-ids <peer-relation> -> empty;
* leader-elected: relation-ids <peer-relation> -> empty;
* config-changed: relation-ids <peer-relation> -> empty;
* start: relation-ids <peer-relation> -> empty;

* update-status (or any other hook after start): relation-ids <peer-relation> -> <peer-relation>:0

When `start` is executed, I would like to set some values in the peer app relation data (e.g. a database cluster ID bootstrapped by the leader unit) regardless of the presence of other units on that relation.

A similar scenario is possible to do via `leader-set` but if it is intended to be replaced with peer app relation data there needs to be an alternative. `leader-set` is usable when `leader-elected` is run hence the bug title is about the time `leader-elected` is executed.

Ideas:

* <peer>-relation-joined for the app relation data bag (even if there is only one unit present in a peer relation);

i.e.
start: relation-ids <peer-relation> -> empty;
<peer>-relation-joined, JUJU_REMOTE_UNIT="", JUJU_REMOTE_APP=<this-app-name>: relation-ids <peer-relation> -> <peer>:0;

* make the peer relation available during `leader-elected` hook execution (there can be multiple peer relations though which can be problematic for this case).

Gustavo Niemeyer (niemeyer) wrote :

We've just discussed this in today's Charm Tech standup, and the fix for this might be two complementary changes:

1) We need a new hook which has actually been discussed before: <name>-relation-created; This is fired as soon as a relation is established, and before any units are accounted as joined as far as the local unit agent knows about. This hook fires once for each relation ID, and is the missing complement of <name>-relation-broken.

2) Specifically for peer relations, we can account the relation as created to begin with, since it's more of a circle of friends, and the local unit itself is part of that relation as soon as it's alive. In other words, all peer relations would fire <name>-relation-created, even if the local unit is the single participant right now.

With both of these features in place, we have a nice point to set data on the application even before any further units join.

Richard Harding (rharding) wrote :

As noted we've got some fixes going in to assist with this going forward.

Changed in juju:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.8-beta1
Changed in juju:
assignee: nobody → Achilleas Anagnostopoulos (achilleasa)
status: Triaged → In Progress

PR https://github.com/juju/juju/pull/11341 makes the relation-created hook available on the develop branch

Changed in juju:
status: In Progress → Fix Committed
Harry Pidcock (hpidcock) on 2020-06-04
Changed in juju:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers