Merge lp:~hazmat/pyjuju/peers-from-hurd into lp:pyjuju
Proposed by
Kapil Thangavelu
Status: | Merged |
---|---|
Merged at revision: | 615 |
Proposed branch: | lp:~hazmat/pyjuju/peers-from-hurd |
Merge into: | lp:pyjuju |
Diff against target: |
138 lines (+60/-12) 3 files modified
juju/control/remove_relation.py (+1/-1) juju/unit/lifecycle.py (+39/-5) juju/unit/tests/test_lifecycle.py (+20/-6) |
To merge this branch: | bzr merge lp:~hazmat/pyjuju/peers-from-hurd |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+148528@code.launchpad.net |
Description of the change
Unit process multiple relations in defined order.
Previously when unit agents were being notified of multiple relations, typicaly
at startup, they would process them in essentially random order. This would
complicate things for applications that would have peer relations as well, for
ha or replication, as they couldn't tell if they were being run standalone or
in a cluster/quorum. Instead when a unit has multiple relations, we process
peer relations first followed by client/server relations.
To post a comment you must log in.
Reviewers: mp+148528_ code.launchpad. net,
Message:
Please take a look.
Description:
Unit process multiple relations in defined order.
Previously when unit agents were being notified of multiple relations,
typicaly
at startup, they would process them in essentially random order. This
would
complicate things for applications that would have peer relations as
well, for
ha or replication, as they couldn't tell if they were being run
standalone or
in a cluster/quorum. Instead when a unit has multiple relations, we
process
the relations in creation order, given that a service's peer relations
are
always created upon service deploy, this gives deterministic behavior
that
solves the use case instead of previous random order.
https:/ /code.launchpad .net/~hazmat/ juju/peers- from-hurd/ +merge/ 148528
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/7341044/
Affected files: lifecycle. py tests/test_ lifecycle. py
A [revision details]
M juju/unit/
M juju/unit/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: juju/unit/ lifecycle. py lifecycle. py' lifecycle. py 2012-09-10 03:20:20 +0000 lifecycle. py 2013-02-14 18:29:42 +0000
(service_ relation. internal_ relation_ id, service_relation)
for service_relation in old_relations)
=== modified file 'juju/unit/
--- juju/unit/
+++ juju/unit/
@@ -374,8 +374,15 @@
- added = set(new_ relations. keys()) - set(self. _relations. keys()) _relations. keys()) - set(new_ relations. keys()) set(new_ relations. keys()) - _relations. keys()) ) sorted( _relations. keys()) - set(new_ relations. keys()) )))
is_principal = not (yield self._service. is_subordinate( ))
- removed = set(self.
+ # We process new relations in creation order, and remove rels
+ # most recently created to oldest. As a consequence, this
+ # ensures that new peer relations are processed (created at
+ # service deployment) are processed before client/server
+ # relations when multiple rels are available at unit startup.
+ added = sorted(
set(self.
+ removed = list(reversed(
+ set(self.
+
# Could this service be a principal container?
@@ -404,12 +411,13 @@
yield workflow. transition_ state(" departed" )
self._store_ relations( )
- # Process new relations.
service_ relation = new_relations[ relation_ id] relation( service_ relation) relation. relation_ scope subordinate_ unit(service_ relation) relation. relation_ scope == "container"): subordinate_ unit(service_ relation) relations( )
+ # Process new relations
for relation_id in added:
yield self._add_
- if (is_principal and service_
== "container"):
- self._add_
+ if (is_principal
+ and service_
+ yield self._add_
yield self._store_
@i...