Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 Subordinate service implementation details | 1 Subordinate service implementation details |
2 =========================================== | 2 =========================================== |
3 | 3 |
4 | 4 |
5 This document explains the implementation of subordinate services. For | 5 This document explains the implementation of subordinate services. For |
6 a higher level understanding please refer to the primary :doc:`subordinates | 6 a higher level understanding please refer to the primary :doc:`subordinates |
7 document <subordinate-services>`. | 7 document <subordinate-services>`. |
8 | 8 |
9 | 9 |
10 Overview | 10 Overview |
11 ------- | 11 ------- |
12 | 12 |
13 Principal services can have relationships with subordinates. This is | 13 Principal services can have relationships with subordinates. This is |
14 modeled using extensions to the `client-server` relationship | 14 modeled using extensions to the `client-server` relationship |
15 type. This new relation type is used exclusively between subordinates | 15 type. This new relation type is used exclusively between subordinates |
16 and principals and is used to limit communication to only service | 16 and principals and is used to limit communication to only service |
17 units in the same container. | 17 units in the same container. |
18 | 18 |
19 | 19 |
20 ZooKeeper state | 20 ZooKeeper state |
21 --------------- | 21 --------------- |
22 | 22 |
23 Subordinate relations use the normal `client-server` relationship type | 23 Subordinate relations use the normal `client-server` relationship type |
24 but store additional information in the relation nodes to maintain a | 24 but store additional information in the relation nodes to maintain a |
25 1-1 mapping from the unit-id of the principal to the unit id of the | 25 1-1 mapping from the unit-id of the principal to the unit id of the |
26 subordinate. :: | 26 subordinate. :: |
27 | 27 |
28 relations/ | 28 relations/ |
29 relation-000000001/ | 29 relation-000000001/ |
30 container_relations/ | 30 unit-00000001/ |
niemeyer
2012/02/10 00:20:39
s/_/-/
| |
31 | subordinate_id-00000002: principal_id-00000001 | 31 client/ |
32 | subordinate_id-00000004: principal_id-00000003 | 32 unit-000000002/ |
33 --------------------------------------------------- | 33 server/ |
34 settings/ | 34 unit-000000001/ |
35 principal_id-00000001/ | 35 settings/ |
36 | private-address: 10.2.2.2 | 36 unit-00000001/ |
37 ------------------------------- | 37 | private-address: 10.2.2.2 |
38 principal_id-00000003/ | 38 ------------------------------- |
39 | private-address: 10.2.2.3 | 39 unit-00000004/ |
40 --------------------------------------------------- | 40 client/ |
41 unit-000000003/ | |
42 server/ | |
43 unit-000000004/ | |
44 settings/ | |
45 unit-00000004/ | |
46 | private-address: 10.2.2.4 | |
47 ------------------------------- | |
48 relation-000000002/ | |
49 client/ | |
50 unit-000000002/ | |
51 server/ | |
52 unit-000000001/ | |
53 settings/ | |
54 unit-00000001/ | |
55 | private-address: 10.2.2.2 | |
56 ------------------------------- | |
41 | 57 |
42 Elements ending with **/** refer to ZK nodes with its children | 58 Elements ending with **/** refer to ZK nodes with its children |
43 indented under it.. Elements preceded by **|** represent a YAML | 59 indented under it. Elements preceded by **|** represent a YAML |
niemeyer
2012/02/10 00:20:39
s/.././
| |
44 encoded structure under the preceding ZK node. `container_relations` | 60 encoded structure under the preceding ZK node. The new logical |
niemeyer
2012/02/10 00:20:39
s/under/within/
niemeyer
2012/02/10 18:28:30
Missing this fix. The YAML content goes within the
| |
45 is a new structure under the each relations ZK node. This contains a | 61 structure is :: |
46 mapping from the subordinate unit's id to the id of its principal | 62 |
47 services' unit agent. This representation takes advantage of the fact | 63 relations/ |
48 that while a principal can have many subordinates a subordinate can | 64 relation-<id>/ |
49 only have one principal. In the context of a given relationship this | 65 unit-<principal id>/ # omitted for global scoped relations |
50 mapping is unique. | 66 <role>/ {name: <name>, role: <role>} |
67 - list of unit presence nodes | |
68 | |
69 The containment structure varies based on the type of | |
70 relationship. Container scoped relations have an additional level of | |
71 nesting in the structure which is the unit id of the container for a | |
72 given pair of relationship endpoints. Globally scoped relations have | |
73 the "client", "server" and "settings" nodes directly under the | |
74 "relation-<id>" node. Supplemental information from the topology | |
75 enables this structure to be used in the construction of watches. | |
51 | 76 |
52 Additionally there are changes related to the storage of the relation | 77 Additionally there are changes related to the storage of the relation |
53 in the topology. A `relation_scope` is added to the ordered list of | 78 in the topology. Keys are added per relationship, including |
54 properties such that :: | 79 `interface` (previously referred to as relation_type), `scope` which |
80 is the relation scope (at runtime) and services which includes the | |
81 `name` and `role` mappings of each service participating in the | |
82 relationship. :: | |
55 | 83 |
56 relations | 84 relations |
57 relation-00000001: | 85 relation-00000001: |
58 - relation_type | 86 interface: name |
59 - relation_scope | 87 scope: name |
60 - service-00000001: {name: name, role: role} | 88 services: |
61 service-00000002: {name: name, role: role} | 89 service-00000001: {name: <name>, role: <role>} |
niemeyer
2012/02/10 00:20:39
Let's take the chance to update this, as we discus
bcsaller
2012/02/10 01:32:26
Done.
| |
90 service-00000002: {name: <name>, role: <role>} | |
91 | |
92 This change resulted in the topology VERSION being incremented from 1 | |
93 to 2. Migration from the old topology to the newer VERSION is handled | |
94 automatically and is transparent, even with existing deployments. | |
62 | 95 |
63 | 96 |
64 Watch related changes | 97 Watch related changes |
65 --------------------- | 98 --------------------- |
66 | 99 |
67 The unit agent will use watch_relation_states to see when new | 100 The unit agent will use watch_relation_states to see when new |
68 relations are added. When a subordinate relation is present deployment | 101 relations are added. When a subordinate relation is present deployment |
69 actions will be taken in the unit agents lifecycle. | 102 actions will be taken in the unit agents lifecycle. |
70 | 103 |
71 UnitRelationStates.watch_related_units will dispatch on the relation | 104 UnitRelationStates.watch_related_units will dispatch on the relation |
72 and only establish watches between the principal and subordinate units | 105 and only establish watches between the principal and subordinate units |
73 in the same container. | 106 in the same container. |
74 | 107 |
75 Deployment | 108 Deployment |
76 ---------- | 109 ---------- |
77 | 110 |
78 `juju deploy` needs to enforce that services which require `scope: | 111 `juju deploy` needs to enforce that services where `subordinate: true` |
79 container` relations are not deployed until one of those relationships | 112 is defined are not deployed until a `scope: conatiner` relationship is |
80 have been satisfied. | 113 added to a charm which is `subordinate: false`. |
niemeyer
2012/02/10 00:20:39
As we discussed online, adding a "scope: container
bcsaller
2012/02/10 01:32:26
Done.
| |
81 | 114 |
82 The UnitMachineDeployment/UnitContainerDeployment in machine/unit will | 115 The UnitMachineDeployment/UnitContainerDeployment in machine/unit will |
83 undergo minor refactoring to make it more easily useable by the | 116 undergo minor refactoring to make it more easily useable by the |
84 UnitAgent to do its deployment of subordinate services. The Unit Agent | 117 UnitAgent to do its deployment of subordinate services. The Unit Agent |
85 is the only entity with direct a relationship to its subordinate unit | 118 is the only entity with direct a relationship to its subordinate unit |
86 and so the UnitAgent does the deployment of its subordinate units | 119 and so the UnitAgent does the deployment of its subordinate units |
87 rather than the MachineAgent. This model will continue to work in | 120 rather than the MachineAgent. This model will continue to work in the |
88 the expected LXCEverywhere future. | 121 expected LXCEverywhere future. |
89 | 122 |
90 When a subordinate unit is deployed it is assigned the public and private | 123 When a subordinate unit is deployed it is assigned the public and private |
91 addresses of its principal service (even though it may expose its own | 124 addresses of its principal service (even though it may expose its own |
92 ports). This is because networking is dependent on the container its | 125 ports). This is because networking is dependent on the container its |
93 running it, i.e, that of the principal's service unit. | 126 running it, i.e, that of the principal's service unit. |
94 | 127 |
95 One interesting caveat is that we don't assign the subordinate unit a | 128 One interesting caveat is that we don't assign the subordinate unit a |
96 machine id. `juju-status` exposes this information in a way that is | 129 machine id. `juju-status` exposes this information in a way that is |
97 clear and is outlined below. Machine assignment is currently used to | 130 clear and is outlined below. Machine assignment is currently used to |
98 trigger a class of deployment activities which subordinate services do | 131 trigger a class of deployment activities which subordinate services do |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 subordinate-charms # (charm metadata support) | 192 subordinate-charms # (charm metadata support) |
160 subordinate-implicit-interfaces # (juju-info) | 193 subordinate-implicit-interfaces # (juju-info) |
161 subordinate-relation-type | 194 subordinate-relation-type |
162 | 195 |
163 subordinate-control-deploy | 196 subordinate-control-deploy |
164 subordinate-control-units # (add/remove) | 197 subordinate-control-units # (add/remove) |
165 subordinate-control-status | 198 subordinate-control-status |
166 | 199 |
167 subordinate-control-relations # (add/remove) | 200 subordinate-control-relations # (add/remove) |
168 subordinate-unit-agent-deploy | 201 subordinate-unit-agent-deploy |
LEFT | RIGHT |