Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1265)

Side by Side Diff: source/drafts/relation-reference.rst

Issue 5836049: Add support for using relation ids to refer unambiguously to relations.
Patch Set: Add support for using relation ids to refer unambiguously to relations. Created 5 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « [revision details] ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 Relation references
2 -------------------
niemeyer 2012/03/20 13:31:22 Please check the other specs to see how they forma
jimbaker 2012/03/22 04:17:53 Done.
3
4 A service may **provide** an interface to multiple consuming services
5 with the same relation name; each of these is a different established
6 relation. For example, the ``mysql5`` service might provide the
7 ``mysql`` interface to multiple consuming clients using the relation
8 name ``db``. When interacting with a given consuming client, relation
9 hooks executing on ``mysql5`` service units in turn would be named
10 ``db-relation-joined``, ``db-relation-changed``, and
11 ``db-relation-departed``. In addition, the environment variable
12 `$JUJU_RELATION` would be set to ``db``.
13
14 This scenario implies that there is potential ambiguity in using the
15 relation name to refer to the specific relation between a provider and
16 a consumer. However, this ambiguity is currently rarely seen. This is
17 because relation hooks are always executed in the context of a
18 specific relation, as well as any settings on this relation. This
19 locality avoids most ambiguity in actual usage.
20
21 But ambiguity can arise in the following scenarios:
22
23 * Relation hooks are used to change local state, so it is currently
24 possible for the ambiguity in referring to a relation to become
25 visible over cumulative hook executions. Using appropriate
26 relation settings can be used to distinguish the consumer, so
27 there is a workaround.
28
29 * To enable the new feature of using relation hook commands to
30 work with other relations, or for these hook commands to be used
31 in nonrelation hooks, it is essential to have a nonambiguous
32 reference.
33
34 Therefore, to completely specify a relation, it is necessary to use
35 its relation id, not the relation name. However, the use of relation
niemeyer 2012/03/20 13:31:22 Remove content after the dot. We'll use it later.
jimbaker 2012/03/22 04:17:53 Done.
niemeyer 2012/03/22 18:20:40 Not done.
36 ids is restricted: relation ids are only visible inside relation hooks
37 and/or relation hook commands. In particular, they are never seen in
38 `juju status` output.
39
40 To ensure readibility of the relation id, its format is specified to
41 be::
42
43 <relation name>:<normalized internal relation id>
44
45 Normalization removes any padding zeros from the internal id. In
46 addition, a new environment variable, `$JUJU_RELATION_ID`, will always
niemeyer 2012/03/20 13:31:22 In addition to normalization we're setting an envi
jimbaker 2012/03/22 04:17:53 Done.
niemeyer 2012/03/22 18:20:40 Not done.
47 be set to the relation id in the context of relation hooks.
48
49 For example, if the relation is associated with relation name ``db`` and
50 the specific interal relation id is ``relation-0000000042``, then the
51 relation id is ``db:42``. The relation hooks ``db-relation-joined``,
52 etc., will have `$JUJU_RELATION_ID` set to ``db:42``. In addition,
53 this format further implies that relation id is not globally
54 unique. If the provider uses the relation name ``db`` and a consumer
55 uses the relation name ``database``, then for interal relation id
56 ``relation-0000000042``, ``db:42`` and ``database:42`` could both be
57 in use. However, it is not intended that relation ids be shared, or
58 even publicly visible to an admin, so this should not pose an issue.
59
60
61 References
62 ~~~~~~~~~~
niemeyer 2012/03/20 13:31:22 I believe we use --- for internal headers.
jimbaker 2012/03/22 04:17:53 Done.
63
64 Motivation for relation ids is mentioned in `bug #767195:
65 https://bugs.launchpad.net/juju/+bug/767195`_: Hooks must be able to
66 enumerate and query relations. In addition, possible formats are
67 discussed.
OLDNEW
« no previous file with comments | « [revision details] ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 204d58d